File tree Expand file tree Collapse file tree 9 files changed +110
-3
lines changed
src/compiler/compile/render_dom/wrappers
raw-mustache-before-element Expand file tree Collapse file tree 9 files changed +110
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ export default class RawMustacheTagWrapper extends Tag {
39
39
}
40
40
41
41
else {
42
- const needs_anchor = in_head || ( this . next && ! this . next . is_dom_node ( ) ) ;
42
+ const needs_anchor = in_head || ( this . next && ! this . next . is_dom_node ( ) ) || ! this . parent || ! this . parent . is_dom_node ( ) ;
43
43
44
44
const html_tag = block . get_unique_name ( 'html_tag' ) ;
45
45
const html_anchor = needs_anchor && block . get_unique_name ( 'html_anchor' ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ export let content;
3
+ </script >
4
+
5
+ {@html content }
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `
3
+ <button>Switch</button>
4
+ <p>Another first line</p>
5
+ <p>This line should be last.</p>
6
+ ` ,
7
+ async test ( { assert, target, window } ) {
8
+ const btn = target . querySelector ( "button" ) ;
9
+ const clickEvent = new window . MouseEvent ( "click" ) ;
10
+
11
+ await btn . dispatchEvent ( clickEvent ) ;
12
+
13
+ assert . htmlEqual (
14
+ target . innerHTML ,
15
+ `
16
+ <button>Switch</button>
17
+ <p>First line</p>
18
+ <p>This line should be last.</p>
19
+ `
20
+ ) ;
21
+
22
+ await btn . dispatchEvent ( clickEvent ) ;
23
+
24
+ assert . htmlEqual (
25
+ target . innerHTML ,
26
+ `
27
+ <button>Switch</button>
28
+ <p>Another first line</p>
29
+ <p>This line should be last.</p>
30
+ `
31
+ ) ;
32
+ } ,
33
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import RawMustache from ' ./RawMustache.svelte' ;
3
+
4
+ let content1 = ` <p>First line</p>` ;
5
+ let content2 = ` <p>Another first line</p>`
6
+
7
+ let show = false ;
8
+ $: content = show ? content1 : content2;
9
+ </script >
10
+
11
+ <button on:click ={() => show = ! show }>
12
+ Switch
13
+ </button >
14
+
15
+ <RawMustache {content } />
16
+
17
+ <p >This line should be last.</p >
Original file line number Diff line number Diff line change
1
+ <slot />
2
+ <p >This line should be last.</p >
Original file line number Diff line number Diff line change 1
1
export default {
2
- html : `<p>x<span>baz</span></p>`
2
+ html : `
3
+ <button>Switch</button>
4
+ <p>Another first line</p>
5
+ <p>This line should be last.</p>
6
+ ` ,
7
+ async test ( { assert, target, window } ) {
8
+ const btn = target . querySelector ( "button" ) ;
9
+ const clickEvent = new window . MouseEvent ( "click" ) ;
10
+
11
+ await btn . dispatchEvent ( clickEvent ) ;
12
+
13
+ assert . htmlEqual (
14
+ target . innerHTML ,
15
+ `
16
+ <button>Switch</button>
17
+ <p>First line</p>
18
+ <p>This line should be last.</p>
19
+ `
20
+ ) ;
21
+
22
+ await btn . dispatchEvent ( clickEvent ) ;
23
+
24
+ assert . htmlEqual (
25
+ target . innerHTML ,
26
+ `
27
+ <button>Switch</button>
28
+ <p>Another first line</p>
29
+ <p>This line should be last.</p>
30
+ `
31
+ ) ;
32
+ } ,
3
33
} ;
Original file line number Diff line number Diff line change 1
- <p >{@html ' x' }<span >baz</span ></p >
1
+ <script >
2
+ import Component from ' ./Component.svelte' ;
3
+
4
+ let content1 = ` <p>First line</p>` ;
5
+ let content2 = ` <p>Another first line</p>`
6
+
7
+ let show = false ;
8
+ $: content = show ? content1 : content2;
9
+ </script >
10
+
11
+ <button on:click ={() => show = ! show }>
12
+ Switch
13
+ </button >
14
+
15
+ <Component >
16
+ {@html content }
17
+ </Component >
Original file line number Diff line number Diff line change
1
+ export default {
2
+ html : `<p>x<span>baz</span></p>`
3
+ } ;
Original file line number Diff line number Diff line change
1
+ <p >{@html ' x' }<span >baz</span ></p >
You can’t perform that action at this time.
0 commit comments