From 24e09efec102a1bbb12ca4260fe3aee4063ef918 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Thu, 21 Feb 2019 23:34:27 -0500 Subject: [PATCH] fix slot block lineage - fixes #2124 --- src/compile/render-dom/wrappers/Element/index.ts | 5 +++-- .../samples/component-slot-named-c/Nested.svelte | 1 + .../runtime/samples/component-slot-named-c/_config.js | 6 ++++++ .../samples/component-slot-named-c/main.svelte | 11 +++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/component-slot-named-c/Nested.svelte create mode 100644 test/runtime/samples/component-slot-named-c/_config.js create mode 100644 test/runtime/samples/component-slot-named-c/main.svelte diff --git a/src/compile/render-dom/wrappers/Element/index.ts b/src/compile/render-dom/wrappers/Element/index.ts index b08c438002..78a50d36ac 100644 --- a/src/compile/render-dom/wrappers/Element/index.ts +++ b/src/compile/render-dom/wrappers/Element/index.ts @@ -132,7 +132,7 @@ export default class ElementWrapper extends Wrapper { const name = attribute.getStaticValue(); if (!(owner as InlineComponentWrapper).slots.has(name)) { - const child_block = block.parent.child({ + const child_block = block.child({ comment: createDebuggingComment(node, this.renderer.component), name: this.renderer.component.getUniqueName(`create_${sanitize(name)}_slot`) }); @@ -205,7 +205,8 @@ export default class ElementWrapper extends Wrapper { block.parent.addDependencies(block.dependencies); // appalling hack - block.parent.wrappers.splice(block.parent.wrappers.indexOf(this), 1); + const index = block.parent.wrappers.indexOf(this); + block.parent.wrappers.splice(index, 1); block.wrappers.push(this); } } diff --git a/test/runtime/samples/component-slot-named-c/Nested.svelte b/test/runtime/samples/component-slot-named-c/Nested.svelte new file mode 100644 index 0000000000..a94392ce5d --- /dev/null +++ b/test/runtime/samples/component-slot-named-c/Nested.svelte @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/runtime/samples/component-slot-named-c/_config.js b/test/runtime/samples/component-slot-named-c/_config.js new file mode 100644 index 0000000000..adfd944e26 --- /dev/null +++ b/test/runtime/samples/component-slot-named-c/_config.js @@ -0,0 +1,6 @@ +export default { + html: ` + Hello + world + ` +}; diff --git a/test/runtime/samples/component-slot-named-c/main.svelte b/test/runtime/samples/component-slot-named-c/main.svelte new file mode 100644 index 0000000000..86ae062850 --- /dev/null +++ b/test/runtime/samples/component-slot-named-c/main.svelte @@ -0,0 +1,11 @@ + + + + Hello + + + + world + \ No newline at end of file