File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ export default class Block {
164
164
165
165
if ( parent_node ) {
166
166
this . builders . mount . add_line ( `@append(${ parent_node } , ${ name } );` ) ;
167
- if ( parent_node === 'document.head' ) this . builders . destroy . add_line ( `@detach(${ name } );` ) ;
167
+ if ( parent_node === 'document.head' && ! no_detach ) this . builders . destroy . add_line ( `@detach(${ name } );` ) ;
168
168
} else {
169
169
this . builders . mount . add_line ( `@insert(#target, ${ name } , anchor);` ) ;
170
170
if ( ! no_detach ) this . builders . destroy . add_conditional ( 'detaching' , `@detach(${ name } );` ) ;
Original file line number Diff line number Diff line change @@ -21,9 +21,18 @@ export default class RawMustacheTagWrapper extends Tag {
21
21
render ( block : Block , parent_node : string , parent_nodes : string ) {
22
22
const name = this . var ;
23
23
24
+ const in_head = parent_node === 'document.head' ;
25
+ const needs_anchors = ! parent_node || in_head ;
26
+
27
+ // if in head always needs anchors
28
+ if ( in_head ) {
29
+ this . prev = null ;
30
+ this . next = null ;
31
+ }
32
+
24
33
// TODO use is_dom_node instead of type === 'Element'?
25
- const needs_anchor_before = this . prev ? this . prev . node . type !== 'Element' : ! parent_node ;
26
- const needs_anchor_after = this . next ? this . next . node . type !== 'Element' : ! parent_node ;
34
+ const needs_anchor_before = this . prev ? this . prev . node . type !== 'Element' : needs_anchors ;
35
+ const needs_anchor_after = this . next ? this . next . node . type !== 'Element' : needs_anchors ;
27
36
28
37
const anchor_before = needs_anchor_before
29
38
? block . get_unique_name ( `${ name } _before` )
@@ -89,7 +98,7 @@ export default class RawMustacheTagWrapper extends Tag {
89
98
90
99
block . builders . mount . add_line ( insert ( init ) ) ;
91
100
92
- if ( ! parent_node ) {
101
+ if ( needs_anchors ) {
93
102
block . builders . destroy . add_conditional ( 'detaching' , needs_anchor_before
94
103
? `${ detach } \n@detach(${ anchor_before } );`
95
104
: detach ) ;
@@ -100,4 +109,4 @@ export default class RawMustacheTagWrapper extends Tag {
100
109
add_anchor_after ( ) ;
101
110
}
102
111
}
103
- }
112
+ }
You can’t perform that action at this time.
0 commit comments