mirror of https://github.com/sveltejs/svelte
fixes #10013
parent
fa3e4d004a
commit
f0d9919fc9
@ -0,0 +1,62 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [b1, b2, b3, b4] = target.querySelectorAll('button');
|
||||
|
||||
b1?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button class="blue">blue</button>
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
`
|
||||
);
|
||||
|
||||
b2?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
<button class="red">red</button>
|
||||
<button class="red">red</button>
|
||||
`
|
||||
);
|
||||
|
||||
b3?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
<button class="red">red</button>
|
||||
`
|
||||
);
|
||||
|
||||
b4?.click();
|
||||
await Promise.resolve();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
<button class="blue">blue</button>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,24 @@
|
||||
<script>
|
||||
let tag = $state('button');
|
||||
let values = $state({ a: 'red', b: 'red', c: 'red', d: 'red' });
|
||||
|
||||
let count = 0;
|
||||
const factory = (name) => {
|
||||
count++;
|
||||
// check that spread effects are isolated from each other
|
||||
if (count > 8) throw new Error('too many calls');
|
||||
|
||||
return {
|
||||
class: values[name],
|
||||
onclick: () => {
|
||||
values[name] = 'blue';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<button {...factory('a')}>{values.a}</button>
|
||||
<button {...factory('b')}>{values.b}</button>
|
||||
|
||||
<svelte:element this={tag} {...factory('c')}>{values.c}</svelte:element>
|
||||
<svelte:element this={tag} {...factory('d')}>{values.d}</svelte:element>
|
||||
Loading…
Reference in new issue