0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 17:30:59 +01:00
svelte/test/runtime/samples/each-block-keyed/_config.js
Rich Harris f45e2b70fd
Implement reactive assignments (#1839)
This also includes elements of RFCs 2 and 3
2018-12-15 19:18:03 -05:00

28 lines
726 B
JavaScript

export default {
props: {
todos: [
{ id: 123, description: 'implement keyed each blocks' },
{ id: 234, description: 'implement client-side hydration' }
]
},
html: `
<p>1: implement keyed each blocks</p>
<p>2: implement client-side hydration</p>
`,
test({ assert, component, target }) {
const [ p1, p2 ] = target.querySelectorAll('p');
component.todos = [
{ id: 234, description: 'implement client-side hydration' }
];
assert.htmlEqual(target.innerHTML, '<p>1: implement client-side hydration</p>');
const [ p3 ] = target.querySelectorAll('p');
assert.ok(!target.contains(p1), 'first <p> element should be removed');
assert.equal(p2, p3, 'second <p> element should be retained');
}
};