mirror of https://github.com/sveltejs/svelte
fix: improve attribute directive reactivity detection (#9907)
parent
4e61db7201
commit
b0511a5966
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: improve attribute directive reactivity detection
|
@ -0,0 +1,16 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<div style="color: red;"></div><div class="red"></div><button>toggle</button`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1] = target.querySelectorAll('button');
|
||||
|
||||
b1?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
'<div class="blue" style="color: blue;"></div><div class="blue"></div><button>toggle</button>'
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
let value = $state('red');
|
||||
|
||||
const getValue = () => {
|
||||
return value;
|
||||
}
|
||||
const getClass = () => {
|
||||
return value === 'blue';
|
||||
}
|
||||
const getSpread = () => {
|
||||
return { class: value };
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class:blue={getClass()} style:color={getValue()}></div>
|
||||
<div {...getSpread()}></div>
|
||||
<button on:click={() => value = 'blue'}>toggle</button>
|
||||
|
Loading…
Reference in new issue