mirror of https://github.com/sveltejs/svelte
fix: improve spreading of attributes (#11177)
* fix: improve spreading of attributes * twakpull/11176/head
parent
d061f2f137
commit
2fa095b61e
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: improve spreading of attributes
|
@ -0,0 +1,23 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const btn = target.querySelector('button');
|
||||
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(target.innerHTML, `<button>Toggle</button><h1>Style: not red</h1>`);
|
||||
|
||||
flushSync(() => {
|
||||
btn?.click();
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<button>Toggle</button><h1 data-red="true">Style: red</h1>`
|
||||
);
|
||||
}
|
||||
});
|
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
let isRed = $state(true)
|
||||
|
||||
const attributes = $derived({
|
||||
'data-red': isRed ? true : undefined
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={() => isRed = !isRed }>Toggle</button>
|
||||
|
||||
<h1 {...attributes}>Style: {isRed ? 'red' : 'not red'}</h1>
|
Loading…
Reference in new issue