From c904e21674f805145a69596c54bec20f0f6aca0f Mon Sep 17 00:00:00 2001 From: Mikhail Korepanov Date: Wed, 17 Apr 2019 01:12:24 +0300 Subject: [PATCH] Fix creation of debugging comment for elements without children --- .../render-dom/wrappers/shared/create_debugging_comment.ts | 2 +- test/runtime/samples/component-slot-empty-b/Nested.svelte | 3 +++ test/runtime/samples/component-slot-empty-b/_config.js | 3 +++ test/runtime/samples/component-slot-empty-b/main.svelte | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/component-slot-empty-b/Nested.svelte create mode 100644 test/runtime/samples/component-slot-empty-b/_config.js create mode 100644 test/runtime/samples/component-slot-empty-b/main.svelte diff --git a/src/compile/render-dom/wrappers/shared/create_debugging_comment.ts b/src/compile/render-dom/wrappers/shared/create_debugging_comment.ts index 55d7b307d3..b32d25c1a4 100644 --- a/src/compile/render-dom/wrappers/shared/create_debugging_comment.ts +++ b/src/compile/render-dom/wrappers/shared/create_debugging_comment.ts @@ -16,7 +16,7 @@ export default function create_debugging_comment( let d; if (node.type === 'InlineComponent' || node.type === 'Element') { - d = node.children[0].start; + d = node.children.length ? node.children[0].start : node.start; while (source[d - 1] !== '>') d -= 1; } else { d = node.expression ? node.expression.node.end : c; diff --git a/test/runtime/samples/component-slot-empty-b/Nested.svelte b/test/runtime/samples/component-slot-empty-b/Nested.svelte new file mode 100644 index 0000000000..008d9e2fbb --- /dev/null +++ b/test/runtime/samples/component-slot-empty-b/Nested.svelte @@ -0,0 +1,3 @@ +
+ +
diff --git a/test/runtime/samples/component-slot-empty-b/_config.js b/test/runtime/samples/component-slot-empty-b/_config.js new file mode 100644 index 0000000000..8c1b13b1d5 --- /dev/null +++ b/test/runtime/samples/component-slot-empty-b/_config.js @@ -0,0 +1,3 @@ +export default { + html: `
` +}; diff --git a/test/runtime/samples/component-slot-empty-b/main.svelte b/test/runtime/samples/component-slot-empty-b/main.svelte new file mode 100644 index 0000000000..f6e2deee9b --- /dev/null +++ b/test/runtime/samples/component-slot-empty-b/main.svelte @@ -0,0 +1,6 @@ + + + +