@ -211,6 +211,10 @@ export default class ElementWrapper extends Wrapper {
}
}
} ) ;
} ) ;
if ( node . dynamic_tag ) {
block . add_dependencies ( node . dynamic_tag . dependencies ) ;
}
if ( this . parent ) {
if ( this . parent ) {
if ( node . actions . length > 0 ||
if ( node . actions . length > 0 ||
node . animation ||
node . animation ||
@ -244,6 +248,14 @@ export default class ElementWrapper extends Wrapper {
b ` ${ node } = ${ render_statement } ; `
b ` ${ node } = ${ render_statement } ; `
) ;
) ;
if ( this . node . dynamic_tag && this . renderer . options . dev ) {
block . chunks . create . push ( b ` @validate_dynamic_element( ${ this . node . dynamic_tag . manipulate ( block ) } ); ` ) ;
if ( renderer . options . hydratable ) {
block . chunks . claim . push ( b ` @validate_dynamic_element( ${ this . node . dynamic_tag . manipulate ( block ) } ); ` ) ;
}
}
if ( renderer . options . hydratable ) {
if ( renderer . options . hydratable ) {
if ( parent_nodes ) {
if ( parent_nodes ) {
block . chunks . claim . push ( b `
block . chunks . claim . push ( b `
@ -278,13 +290,14 @@ export default class ElementWrapper extends Wrapper {
block . chunks . destroy . push ( b ` if (detaching) @detach( ${ node } ); ` ) ;
block . chunks . destroy . push ( b ` if (detaching) @detach( ${ node } ); ` ) ;
}
}
let staticChildren = null ;
// insert static children with textContent or innerHTML
// insert static children with textContent or innerHTML
const can_use_textcontent = this . can_use_textcontent ( ) ;
const can_use_textcontent = this . can_use_textcontent ( ) ;
if ( ! this . node . namespace && ( this . can_use_innerhtml || can_use_textcontent ) && this . fragment . nodes . length > 0 ) {
if ( ! this . node . namespace && ( this . can_use_innerhtml || can_use_textcontent ) && this . fragment . nodes . length > 0 ) {
if ( this . fragment . nodes . length === 1 && this . fragment . nodes [ 0 ] . node . type === 'Text' ) {
if ( this . fragment . nodes . length === 1 && this . fragment . nodes [ 0 ] . node . type === 'Text' ) {
block . chunks . create . push (
staticChildren = b ` ${ node } .textContent = ${ string_literal ( ( this . fragment . nodes [ 0 ] as TextWrapper ) . data ) } ; ` ;
b ` ${ node } .textContent = ${ string_literal ( ( this . fragment . nodes [ 0 ] as TextWrapper ) . data ) } ; `
block . chunks . create . push ( staticChildren ) ;
) ;
} else {
} else {
const state = {
const state = {
quasi : {
quasi : {
@ -303,9 +316,8 @@ export default class ElementWrapper extends Wrapper {
to_html ( ( this . fragment . nodes as unknown as Array < ElementWrapper | TextWrapper > ) , block , literal , state , can_use_raw_text ) ;
to_html ( ( this . fragment . nodes as unknown as Array < ElementWrapper | TextWrapper > ) , block , literal , state , can_use_raw_text ) ;
literal . quasis . push ( state . quasi ) ;
literal . quasis . push ( state . quasi ) ;
block . chunks . create . push (
staticChildren = b ` ${ node } . ${ this . can_use_innerhtml ? 'innerHTML' : 'textContent' } = ${ literal } ; ` ;
b ` ${ node } . ${ this . can_use_innerhtml ? 'innerHTML' : 'textContent' } = ${ literal } ; `
block . chunks . create . push ( staticChildren ) ;
) ;
}
}
} else {
} else {
this . fragment . nodes . forEach ( ( child : Wrapper ) = > {
this . fragment . nodes . forEach ( ( child : Wrapper ) = > {
@ -334,6 +346,23 @@ export default class ElementWrapper extends Wrapper {
this . add_classes ( block ) ;
this . add_classes ( block ) ;
this . add_manual_style_scoping ( block ) ;
this . add_manual_style_scoping ( block ) ;
if ( this . node . dynamic_tag ) {
const dependencies = this . node . dynamic_tag . dynamic_dependencies ( ) ;
if ( dependencies . length ) {
const condition = block . renderer . dirty (
dependencies
) ;
block . chunks . update . push ( b `
if ( $ { condition } ) {
@detach ( $ { node } ) ;
$ { node } = $ { render_statement } ;
$ { staticChildren }
}
` );
}
}
if ( nodes && this . renderer . options . hydratable && ! this . void ) {
if ( nodes && this . renderer . options . hydratable && ! this . void ) {
block . chunks . claim . push (
block . chunks . claim . push (
b ` ${ this . node . children . length > 0 ? nodes : children } .forEach(@detach); `
b ` ${ this . node . children . length > 0 ? nodes : children } .forEach(@detach); `