diff --git a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts index a5367b207d..7d3f727ab1 100644 --- a/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts +++ b/src/compiler/compile/render_dom/wrappers/RawMustacheTag.ts @@ -51,7 +51,7 @@ export default class RawMustacheTagWrapper extends Tag { content => x`${html_tag}.p(${content})` ); - const update_anchor = in_head ? 'null' : needs_anchor ? html_anchor : this.next ? this.next.var : 'null'; + const update_anchor = needs_anchor ? html_anchor : this.next ? this.next.var : 'null'; block.chunks.hydrate.push(b`${html_tag} = new @HtmlTag(${update_anchor});`); block.chunks.mount.push(b`${html_tag}.m(${init}, ${parent_node || '#target'}, ${parent_node ? null : '#anchor'});`); diff --git a/test/runtime/samples/raw-mustache-before-element/_config.js b/test/runtime/samples/raw-mustache-before-element/_config.js index c87971a7f0..61288cbb52 100644 --- a/test/runtime/samples/raw-mustache-before-element/_config.js +++ b/test/runtime/samples/raw-mustache-before-element/_config.js @@ -1,33 +1,3 @@ export default { - html: ` - -
Another first line
-This line should be last.
- `, - async test({ assert, target, window }) { - const btn = target.querySelector("button"); - const clickEvent = new window.MouseEvent("click"); - - await btn.dispatchEvent(clickEvent); - - assert.htmlEqual( - target.innerHTML, - ` - -First line
-This line should be last.
- ` - ); - - await btn.dispatchEvent(clickEvent); - - assert.htmlEqual( - target.innerHTML, - ` - -Another first line
-This line should be last.
- ` - ); - }, + html: `xbaz
` }; diff --git a/test/runtime/samples/raw-mustache-before-element/main.svelte b/test/runtime/samples/raw-mustache-before-element/main.svelte index a022a68e95..69c1d0107d 100644 --- a/test/runtime/samples/raw-mustache-before-element/main.svelte +++ b/test/runtime/samples/raw-mustache-before-element/main.svelte @@ -1,17 +1 @@ - - - - -{@html 'x'}baz
\ No newline at end of file diff --git a/test/runtime/samples/raw-mustache-inside-head/_config.js b/test/runtime/samples/raw-mustache-inside-head/_config.js new file mode 100644 index 0000000000..4a84f5c01d --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-head/_config.js @@ -0,0 +1,16 @@ +export default { + async test({ assert, target, window }) { + const btn = target.querySelector("button"); + const clickEvent = new window.MouseEvent("click"); + + assert.equal(window.document.head.innerHTML.includes(''), true); + + await btn.dispatchEvent(clickEvent); + + assert.equal(window.document.head.innerHTML.includes(''), true); + + await btn.dispatchEvent(clickEvent); + + assert.equal(window.document.head.innerHTML.includes(''), true); + }, +}; diff --git a/test/runtime/samples/raw-mustache-inside-head/main.svelte b/test/runtime/samples/raw-mustache-inside-head/main.svelte new file mode 100644 index 0000000000..25b9fdeee9 --- /dev/null +++ b/test/runtime/samples/raw-mustache-inside-head/main.svelte @@ -0,0 +1,16 @@ + + + + +xbaz
` + html: ` + +Another first line
+This line should be last.
+ `, + async test({ assert, target, window }) { + const btn = target.querySelector("button"); + const clickEvent = new window.MouseEvent("click"); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +First line
+This line should be last.
+ ` + ); + + await btn.dispatchEvent(clickEvent); + + assert.htmlEqual( + target.innerHTML, + ` + +Another first line
+This line should be last.
+ ` + ); + }, }; diff --git a/test/runtime/samples/raw-mustache-inside-slot/main.svelte b/test/runtime/samples/raw-mustache-inside-slot/main.svelte index 69c1d0107d..a022a68e95 100644 --- a/test/runtime/samples/raw-mustache-inside-slot/main.svelte +++ b/test/runtime/samples/raw-mustache-inside-slot/main.svelte @@ -1 +1,17 @@ -{@html 'x'}baz
\ No newline at end of file + + + + +