From 0ee59a03608b08805dc3eeef8ea3ad6ac55cace7 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 18 Nov 2017 14:30:25 -0500 Subject: [PATCH 1/2] failing test for #927 --- .../component-slot-each-block/Nested.html | 3 +++ .../component-slot-each-block/_config.js | 24 +++++++++++++++++++ .../component-slot-each-block/main.html | 13 ++++++++++ 3 files changed, 40 insertions(+) create mode 100644 test/runtime/samples/component-slot-each-block/Nested.html create mode 100644 test/runtime/samples/component-slot-each-block/_config.js create mode 100644 test/runtime/samples/component-slot-each-block/main.html diff --git a/test/runtime/samples/component-slot-each-block/Nested.html b/test/runtime/samples/component-slot-each-block/Nested.html new file mode 100644 index 000000000000..8213363fa090 --- /dev/null +++ b/test/runtime/samples/component-slot-each-block/Nested.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/test/runtime/samples/component-slot-each-block/_config.js b/test/runtime/samples/component-slot-each-block/_config.js new file mode 100644 index 000000000000..34b2302332f0 --- /dev/null +++ b/test/runtime/samples/component-slot-each-block/_config.js @@ -0,0 +1,24 @@ +export default { + data: { + things: [1, 2, 3] + }, + + html: ` +
+ 1 + 2 + 3 +
`, + + test(assert, component, target) { + component.set({ things: [1, 2, 3, 4] }); + assert.htmlEqual(target.innerHTML, ` +
+ 1 + 2 + 3 + 4 +
+ `); + } +}; diff --git a/test/runtime/samples/component-slot-each-block/main.html b/test/runtime/samples/component-slot-each-block/main.html new file mode 100644 index 000000000000..b503c5af53cb --- /dev/null +++ b/test/runtime/samples/component-slot-each-block/main.html @@ -0,0 +1,13 @@ + + {{#each things as thing}} + {{thing}} + {{/each}} + + + \ No newline at end of file From 2f86266e129e26d2e355dbef7dc837054556e04f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 23 Nov 2017 11:01:14 -0500 Subject: [PATCH 2/2] append to the dom, not a document fragment, when updating each block in slot - fixes #927 --- src/generators/dom/visitors/EachBlock.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generators/dom/visitors/EachBlock.ts b/src/generators/dom/visitors/EachBlock.ts index 68b2c38c15ef..fd36e6533d3a 100644 --- a/src/generators/dom/visitors/EachBlock.ts +++ b/src/generators/dom/visitors/EachBlock.ts @@ -21,7 +21,7 @@ export default function visitEachBlock( const iterations = block.getUniqueName(`${each}_blocks`); const params = block.params.join(', '); - const needsAnchor = node.next ? !isDomNode(node.next, generator) : !state.parentNode; + const needsAnchor = node.next ? !isDomNode(node.next, generator) : !state.parentNode || !isDomNode(node.parent, generator); const anchor = needsAnchor ? block.getUniqueName(`${each}_anchor`) : (node.next && node.next.var) || 'null'; @@ -219,7 +219,7 @@ function keyed( `); const dynamic = node._block.hasUpdateMethod; - const parentNode = state.parentNode || `${anchor}.parentNode`; + const parentNode = isDomNode(node.parent, generator) ? node.parent.var : `${anchor}.parentNode`; let destroy; if (node._block.hasOutroMethod) { @@ -414,7 +414,7 @@ function unkeyed( .map(dependency => `changed.${dependency}`) .join(' || '); - const parentNode = state.parentNode || `${anchor}.parentNode`; + const parentNode = isDomNode(node.parent, generator) ? node.parent.var : `${anchor}.parentNode`; if (condition !== '') { const forLoopBody = node._block.hasUpdateMethod