fix: fix insert function

pull/6445/head
Daybrush 5 years ago
parent 2c488f4d61
commit 286cd1fa4c

@ -132,7 +132,7 @@ export function append(target: NodeEx, node: NodeEx) {
export function insert(target: NodeEx, node: NodeEx, anchor?: NodeEx) {
if (is_hydrating && !anchor) {
append(target, node);
} else if (node.parentNode !== target || (anchor && node.nextSibling !== anchor)) {
} else if (node.parentNode !== target || node.nextSibling !== anchor) {
target.insertBefore(node, anchor || null);
}
}

@ -0,0 +1,13 @@
export default {
props: {
titles: [{ name: 'a' }, { name: 'b' }, { name: 'c' }]
},
html: '<div class="container"><p>a</p><p>b</p><p>c</p></div>',
test({ assert, component, target }) {
component.titles = [{ name: 'b' }, { name: 'c' }, { name: 'a' }];
assert.htmlEqual(target.innerHTML, '<div class="container"><p>b</p><p>c</p><p>a</p></div>');
}
};

@ -0,0 +1,8 @@
<script>
export let titles;
</script>
<div class="container">
{#each titles as title (title.name)}
<p>{title.name}</p>
{/each}
</div>
Loading…
Cancel
Save