From a0749f6adb7f27144e81f3b06a29418411abdc61 Mon Sep 17 00:00:00 2001 From: Tan Li Hau Date: Sun, 22 Mar 2020 20:08:32 +0800 Subject: [PATCH] fix creating debugging comment for HTML comment (#4567) --- CHANGELOG.md | 4 ++++ .../render_dom/wrappers/shared/create_debugging_comment.ts | 2 +- test/runtime/samples/component-slot-fallback-4/Inner.svelte | 3 +++ test/runtime/samples/component-slot-fallback-4/_config.js | 5 +++++ test/runtime/samples/component-slot-fallback-4/main.svelte | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/component-slot-fallback-4/Inner.svelte create mode 100644 test/runtime/samples/component-slot-fallback-4/_config.js create mode 100644 test/runtime/samples/component-slot-fallback-4/main.svelte diff --git a/CHANGELOG.md b/CHANGELOG.md index 93a8262121..cbab1872dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Svelte changelog +## Unreleased + +* Fix attaching of JS debugging comments to HTML comments ([#4565](https://github.com/sveltejs/svelte/issues/4565)) + ## 3.20.1 * Fix compiler regression with slots ([#4562](https://github.com/sveltejs/svelte/issues/4562)) diff --git a/src/compiler/compile/render_dom/wrappers/shared/create_debugging_comment.ts b/src/compiler/compile/render_dom/wrappers/shared/create_debugging_comment.ts index 11f1feb841..1bdc473df0 100644 --- a/src/compiler/compile/render_dom/wrappers/shared/create_debugging_comment.ts +++ b/src/compiler/compile/render_dom/wrappers/shared/create_debugging_comment.ts @@ -24,7 +24,7 @@ export default function create_debugging_comment( while (source[d] !== '>') d += 1; d += 1; } - } else if (node.type === 'Text') { + } else if (node.type === 'Text' || node.type === 'Comment') { d = node.end; } else { // @ts-ignore diff --git a/test/runtime/samples/component-slot-fallback-4/Inner.svelte b/test/runtime/samples/component-slot-fallback-4/Inner.svelte new file mode 100644 index 0000000000..9eb3ef1401 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/Inner.svelte @@ -0,0 +1,3 @@ + + + foobar \ No newline at end of file diff --git a/test/runtime/samples/component-slot-fallback-4/_config.js b/test/runtime/samples/component-slot-fallback-4/_config.js new file mode 100644 index 0000000000..b7c2b63ed6 --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/_config.js @@ -0,0 +1,5 @@ +export default { + html: ` + foobar + `, +}; diff --git a/test/runtime/samples/component-slot-fallback-4/main.svelte b/test/runtime/samples/component-slot-fallback-4/main.svelte new file mode 100644 index 0000000000..206ce21def --- /dev/null +++ b/test/runtime/samples/component-slot-fallback-4/main.svelte @@ -0,0 +1,5 @@ + + +