From 7b4c486be94824ee839dada5a98c2b661b88445e Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 5 Mar 2018 10:50:09 -0500 Subject: [PATCH] only apply key to keyed each block, not its children - fixes #1202 --- src/generators/dom/Block.ts | 2 +- test/runtime/samples/if-in-keyed-each/_config.js | 15 +++++++++++++++ test/runtime/samples/if-in-keyed-each/main.html | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/if-in-keyed-each/_config.js create mode 100644 test/runtime/samples/if-in-keyed-each/main.html diff --git a/src/generators/dom/Block.ts b/src/generators/dom/Block.ts index 0d786752dc..49f4f81d86 100644 --- a/src/generators/dom/Block.ts +++ b/src/generators/dom/Block.ts @@ -163,7 +163,7 @@ export default class Block { } child(options: BlockOptions) { - return new Block(Object.assign({}, this, options, { parent: this })); + return new Block(Object.assign({}, this, { key: null }, options, { parent: this })); } contextualise(expression: Node, context?: string, isEventHandler?: boolean) { diff --git a/test/runtime/samples/if-in-keyed-each/_config.js b/test/runtime/samples/if-in-keyed-each/_config.js new file mode 100644 index 0000000000..d7f8c5870d --- /dev/null +++ b/test/runtime/samples/if-in-keyed-each/_config.js @@ -0,0 +1,15 @@ +export default { + data: { + items: [ + { id: 1, name: 'one' }, + { id: 2, name: 'two' } + ] + }, + + html: ` + + ` +}; diff --git a/test/runtime/samples/if-in-keyed-each/main.html b/test/runtime/samples/if-in-keyed-each/main.html new file mode 100644 index 0000000000..1787fa3218 --- /dev/null +++ b/test/runtime/samples/if-in-keyed-each/main.html @@ -0,0 +1,7 @@ + \ No newline at end of file