fix insert function (#6445)

pull/6509/head
Daybrush (Younkue Choi) 4 years ago committed by GitHub
parent b662c7fd41
commit 201a71d8b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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