@ -20,25 +20,30 @@ export default function dom(component, options) {
block . has _outro _method = true ;
const body = [ ] ;
if ( renderer . file _var ) {
const file = component . file ? x ` " ${ component . file } " ` : x ` undefined ` ;
body . push ( b ` const ${ renderer . file _var } = ${ file } ; ` ) ;
const file = component . file ? x ` " ${ component . file } " ` : x ` undefined ` ;
body . push ( b ` const ${ renderer . file _var } = ${ file } ; ` ) ;
}
const css = component . stylesheet . render ( options . filename ) ;
const css _sourcemap _enabled = check _enable _sourcemap ( options . enableSourcemap , 'css' ) ;
if ( css _sourcemap _enabled ) {
css . map = apply _preprocessor _sourcemap ( options . filename , css . map ,
/** @type {string | import('@ampproject/remapping').RawSourceMap | import('@ampproject/remapping').DecodedSourceMap} */ ( options . sourcemap ) ) ;
}
else {
css . map = apply _preprocessor _sourcemap (
options . filename ,
css . map ,
/** @type {string | import('@ampproject/remapping').RawSourceMap | import('@ampproject/remapping').DecodedSourceMap} */ (
options . sourcemap
)
) ;
} else {
css . map = null ;
}
const styles = css _sourcemap _enabled && component . stylesheet . has _styles && options . dev
const styles =
css _sourcemap _enabled && component . stylesheet . has _styles && options . dev
? ` ${ css . code } \n /*# sourceMappingURL= ${ css . map . toUrl ( ) } */ `
: css . code ;
const add _css = component . get _unique _name ( 'add_css' ) ;
const should _add _css = ! ! styles && ( options . customElement || options . css === 'injected' ) ;
if ( should _add _css ) {
body . push ( b `
body . push ( b `
function $ { add _css } ( target ) {
@ append _styles ( target , "${component.stylesheet.id}" , "${styles}" ) ;
}
@ -47,22 +52,27 @@ export default function dom(component, options) {
// fix order
// TODO the deconflicted names of blocks are reversed... should set them here
const blocks = renderer . blocks . slice ( ) . reverse ( ) ;
push _array ( body , blocks . map ( ( block ) => {
push _array (
body ,
blocks . map ( ( block ) => {
// TODO this is a horrible mess — renderer.blocks
// contains a mixture of Blocks and Nodes
if ( ( /** @type {import('./Block.js').default} */ ( block ) ) . render )
return ( /** @type {import('./Block.js').default} */ ( block ) ) . render ( ) ;
if ( /** @type {import('./Block.js').default} */ ( block ) . render )
return /** @type {import('./Block.js').default} */ ( block ) . render ( ) ;
return block ;
} ) ) ;
} )
) ;
if ( options . dev && ! options . hydratable ) {
block . chunks . claim . push ( b ` throw new @_Error("options.hydrate only works if the component was compiled with the \` hydratable: true \` option"); ` ) ;
block . chunks . claim . push (
b ` throw new @_Error("options.hydrate only works if the component was compiled with the \` hydratable: true \` option"); `
) ;
}
const uses _slots = component . var _lookup . has ( '$$slots' ) ;
/** @type {import('estree').Node[] | undefined} */
let compute _slots ;
if ( uses _slots ) {
compute _slots = b `
compute _slots = b `
const $$slots = @ compute _slots ( # slots ) ;
` ;
}
@ -72,30 +82,49 @@ export default function dom(component, options) {
const props = component . vars . filter ( ( variable ) => ! variable . module && variable . export _name ) ;
const writable _props = props . filter ( ( variable ) => variable . writable ) ;
const omit _props _names = component . get _unique _name ( 'omit_props_names' ) ;
const compute _rest = x ` @compute_rest_props( $ $ props, ${ omit _props _names . name } ) ` ;
const compute _rest = x ` @compute_rest_props( $ $ props, ${ omit _props _names . name } ) ` ;
const rest = uses _rest
? b `
? b `
const $ { omit _props _names . name } = [ $ { props . map ( ( prop ) => ` " ${ prop . export _name } " ` ) . join ( ',' ) } ] ;
let $$restProps = $ { compute _rest } ;
`
: null ;
const set = uses _props || uses _rest || writable _props . length > 0 || component . slots . size > 0
? x `
const set =
uses _props || uses _rest || writable _props . length > 0 || component . slots . size > 0
? x `
$ { $$props } => {
$ { uses _props &&
renderer . invalidate ( '$$props' , x ` $ $ props = @assign(@assign({}, $ $ props), @exclude_internal_props( $ $ new_props)) ` ) }
$ { uses _rest &&
$ {
uses _props &&
renderer . invalidate (
'$$props' ,
x ` $ $ props = @assign(@assign({}, $ $ props), @exclude_internal_props( $ $ new_props)) `
)
}
$ {
uses _rest &&
! uses _props &&
x ` $ $ props = @assign(@assign({}, $ $ props), @exclude_internal_props( $ $ new_props)) ` }
$ { uses _rest && renderer . invalidate ( '$$restProps' , x ` $ $ restProps = ${ compute _rest } ` ) }
$ { writable _props . map ( ( prop ) => b ` if (' ${ prop . export _name } ' in ${ $$props } ) ${ renderer . invalidate ( prop . name , x ` ${ prop . name } = ${ $$props } . ${ prop . export _name } ` ) } ; ` ) }
$ { component . slots . size > 0 &&
b ` if (' $ $ scope' in ${ $$props } ) ${ renderer . invalidate ( '$$scope' , x ` $ $ scope = ${ $$props } . $ $ scope ` ) } ; ` }
x ` $ $ props = @assign(@assign({}, $ $ props), @exclude_internal_props( $ $ new_props)) `
}
$ { uses _rest && renderer . invalidate ( '$$restProps' , x ` $ $ restProps = ${ compute _rest } ` ) }
$ { writable _props . map (
( prop ) =>
b ` if (' ${ prop . export _name } ' in ${ $$props } ) ${ renderer . invalidate (
prop . name ,
x ` ${ prop . name } = ${ $$props } . ${ prop . export _name } `
) } ; `
) }
$ {
component . slots . size > 0 &&
b ` if (' $ $ scope' in ${ $$props } ) ${ renderer . invalidate (
'$$scope' ,
x ` $ $ scope = ${ $$props } . $ $ scope `
) } ; `
}
}
`
: null ;
const accessors = [ ] ;
const not _equal = component . component _options . immutable ? x ` @not_equal ` : x ` @safe_not_equal ` ;
const not _equal = component . component _options . immutable ? x ` @not_equal ` : x ` @safe_not_equal ` ;
/** @type {import('estree').Node[] | import('estree').Node} */
let missing _props _check ;
@ -115,19 +144,20 @@ export default function dom(component, options) {
type : 'MethodDefinition' ,
kind : 'get' ,
key : { type : 'Identifier' , name : prop . export _name } ,
value : x ` function() {
return $ { prop . hoistable
value : x ` function() {
return $ {
prop . hoistable
? prop . name
: x ` this. $ $ .ctx[ ${ renderer . context _lookup . get ( prop . name ) . index } ] ` }
: x ` this. $ $ .ctx[ ${ renderer . context _lookup . get ( prop . name ) . index } ] `
}
} `
} ) ;
}
else if ( component . compile _options . dev ) {
} else if ( component . compile _options . dev ) {
accessors . push ( {
type : 'MethodDefinition' ,
kind : 'get' ,
key : { type : 'Identifier' , name : prop . export _name } ,
value : x ` function() {
value : x ` function() {
throw new @ _Error ( "<${component.tag}>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
} `
} ) ;
@ -138,29 +168,27 @@ export default function dom(component, options) {
type : 'MethodDefinition' ,
kind : 'set' ,
key : { type : 'Identifier' , name : prop . export _name } ,
value : x ` function( ${ prop . name } ) {
value : x ` function( ${ prop . name } ) {
this . $$set ( { $ { prop . export _name } : $ { prop . name } } ) ;
@ flush ( ) ;
} `
} ) ;
}
else if ( component . compile _options . dev ) {
} else if ( component . compile _options . dev ) {
accessors . push ( {
type : 'MethodDefinition' ,
kind : 'set' ,
key : { type : 'Identifier' , name : prop . export _name } ,
value : x ` function(value) {
value : x ` function(value) {
throw new @ _Error ( "<${component.tag}>: Cannot set read-only property '${prop.export_name}'" ) ;
} `
} ) ;
}
}
else if ( component . compile _options . dev ) {
} else if ( component . compile _options . dev ) {
accessors . push ( {
type : 'MethodDefinition' ,
kind : 'set' ,
key : { type : 'Identifier' , name : prop . export _name } ,
value : x ` function(value) {
value : x ` function(value) {
throw new @ _Error ( "<${component.tag}>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
} `
} ) ;
@ -187,17 +215,16 @@ export default function dom(component, options) {
type : 'MethodDefinition' ,
kind : 'get' ,
key : { type : 'Identifier' , name : specifier . exported . name } ,
value : x ` function() {
value : x ` function() {
return $ { name }
} `
} ) ;
}
else if ( component . compile _options . dev ) {
} else if ( component . compile _options . dev ) {
accessors . push ( {
type : 'MethodDefinition' ,
kind : 'get' ,
key : { type : 'Identifier' , name : specifier . exported . name } ,
value : x ` function() {
value : x ` function() {
throw new @ _Error ( "<${component.tag}>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'" ) ;
} `
} ) ;
@ -208,29 +235,43 @@ export default function dom(component, options) {
// checking that expected ones were passed
const expected = props . filter ( ( prop ) => prop . writable && ! prop . initialised ) ;
if ( expected . length ) {
missing _props _check = b `
missing _props _check = b `
$$self . $$ . on _mount . push ( function ( ) {
$ { expected . map ( ( prop ) => b `
$ { expected . map (
( prop ) => b `
if ( $ { prop . name } === undefined && ! ( ( '${prop.export_name}' in $$props ) || $$self . $$ . bound [ $$self . $$ . props [ '${prop.export_name}' ] ] ) ) {
@ _console . warn ( "<${component.tag}> was created without expected prop '${prop.export_name}'" ) ;
} ` )}
} `
) }
} ) ;
` ;
}
const capturable _vars = component . vars . filter ( ( v ) => ! v . internal && ! v . global && ! v . name . startsWith ( '$$' ) ) ;
const capturable _vars = component . vars . filter (
( v ) => ! v . internal && ! v . global && ! v . name . startsWith ( '$$' )
) ;
if ( capturable _vars . length > 0 ) {
capture _state = x ` () => ({ ${ capturable _vars . map ( ( prop ) => p ` ${ prop . name } ` ) } }) ` ;
capture _state = x ` () => ({ ${ capturable _vars . map ( ( prop ) => p ` ${ prop . name } ` ) } }) ` ;
}
const injectable _vars = capturable _vars . filter ( ( v ) => ! v . module && v . writable && v . name [ 0 ] !== '$' ) ;
const injectable _vars = capturable _vars . filter (
( v ) => ! v . module && v . writable && v . name [ 0 ] !== '$'
) ;
if ( uses _props || injectable _vars . length > 0 ) {
inject _state = x `
inject _state = x `
$ { $$props } => {
$ { uses _props &&
renderer . invalidate ( '$$props' , x ` $ $ props = @assign(@assign({}, $ $ props), $ $ new_props) ` ) }
$ { injectable _vars . map ( ( v ) => b ` if (' ${ v . name } ' in $ $ props) ${ renderer . invalidate ( v . name , x ` ${ v . name } = ${ $$props } . ${ v . name } ` ) } ; ` ) }
$ {
uses _props &&
renderer . invalidate ( '$$props' , x ` $ $ props = @assign(@assign({}, $ $ props), $ $ new_props) ` )
}
$ { injectable _vars . map (
( v ) =>
b ` if (' ${ v . name } ' in $ $ props) ${ renderer . invalidate (
v . name ,
x ` ${ v . name } = ${ $$props } . ${ v . name } `
) } ; `
) }
}
` ;
props _inject = b `
props _inject = b `
if ( $$props && "$$inject" in $$props ) {
$$self . $inject _state ( $$props . $$inject ) ;
}
@ -251,10 +292,11 @@ export default function dom(component, options) {
if ( ! execution _context && ! scope . block ) {
execution _context = node ;
}
}
else if ( ! execution _context &&
} else if (
! execution _context &&
node . type === 'LabeledStatement' &&
node . label . name === '$' ) {
node . label . name === '$'
) {
execution _context = node ;
}
} ,
@ -279,51 +321,54 @@ export default function dom(component, options) {
component . rewrite _props ( ( { name , reassigned , export _name } ) => {
const value = ` $ ${ name } ` ;
const i = renderer . context _lookup . get ( ` $ ${ name } ` ) . index ;
const insert = reassigned || export _name
? b ` ${ ` $ $ subscribe_ ${ name } ` } () `
: b ` @component_subscribe( $ $ self, ${ name } , #value => $ $ invalidate( ${ i } , ${ value } = #value)) ` ;
const insert =
reassigned || export _name
? b ` ${ ` $ $ subscribe_ ${ name } ` } () `
: b ` @component_subscribe( $ $ self, ${ name } , #value => $ $ invalidate( ${ i } , ${ value } = #value)) ` ;
if ( component . compile _options . dev ) {
return b ` @validate_store( ${ name } , ' ${ name } '); ${ insert } ` ;
return b ` @validate_store( ${ name } , ' ${ name } '); ${ insert } ` ;
}
return insert ;
} ) ;
}
const args = [ x ` $ $ self ` ] ;
const has _invalidate = props . length > 0 ||
const args = [ x ` $ $ self ` ] ;
const has _invalidate =
props . length > 0 ||
component . has _reactive _assignments ||
component . slots . size > 0 ||
capture _state ||
inject _state ;
if ( has _invalidate ) {
args . push ( x ` $ $ props ` , x ` $ $ invalidate ` ) ;
}
else if ( component . compile _options . dev ) {
args . push ( x ` $ $ props ` , x ` $ $ invalidate ` ) ;
} else if ( component . compile _options . dev ) {
// $$props arg is still needed for unknown prop check
args . push ( x ` $ $ props ` ) ;
args . push ( x ` $ $ props ` ) ;
}
// has_create_fragment is intentionally to be true in dev mode.
const has _create _fragment = component . compile _options . dev || block . has _content ( ) ;
if ( has _create _fragment ) {
body . push ( b `
body . push ( b `
function create _fragment ( # ctx ) {
$ { block . get _contents ( ) }
}
` );
}
body . push ( b `
body . push ( b `
$ { component . extract _javascript ( component . ast . module ) }
$ { component . fully _hoisted }
` );
const filtered _props = props . filter ( ( prop ) => {
const variable = component . var _lookup . get ( prop . name ) ;
if ( variable . hoistable )
return false ;
if ( variable . hoistable ) return false ;
return prop . name [ 0 ] !== '$' ;
} ) ;
const reactive _stores = component . vars . filter ( ( variable ) => variable . name [ 0 ] === '$' && variable . name [ 1 ] !== '$' ) ;
const reactive _stores = component . vars . filter (
( variable ) => variable . name [ 0 ] === '$' && variable . name [ 1 ] !== '$'
) ;
const instance _javascript = component . extract _javascript ( component . ast . instance ) ;
const has _definition = component . compile _options . dev ||
const has _definition =
component . compile _options . dev ||
( instance _javascript && instance _javascript . length > 0 ) ||
filtered _props . length > 0 ||
uses _props ||
@ -340,18 +385,21 @@ export default function dom(component, options) {
const variable = component . var _lookup . get ( store . name . slice ( 1 ) ) ;
return ! variable || variable . hoistable ;
} )
. map ( ( { name } ) => b `
$ { component . compile _options . dev && b ` @validate_store( ${ name . slice ( 1 ) } , ' ${ name . slice ( 1 ) } '); ` }
@ component _subscribe ( $$self , $ { name . slice ( 1 ) } , $$value => $$invalidate ( $ { renderer . context _lookup . get ( name ) . index } , $ { name } = $$value ) ) ;
` );
. map (
( { name } ) => b `
$ { component . compile _options . dev && b ` @validate_store( ${ name . slice ( 1 ) } , ' ${ name . slice ( 1 ) } '); ` }
@ component _subscribe ( $$self , $ { name . slice ( 1 ) } , $$value => $$invalidate ( $ {
renderer . context _lookup . get ( name ) . index
} , $ { name } = $$value ) ) ;
`
) ;
const resubscribable _reactive _store _unsubscribers = reactive _stores
. filter ( ( store ) => {
const variable = component . var _lookup . get ( store . name . slice ( 1 ) ) ;
return variable && ( variable . reassigned || variable . export _name ) ;
} )
. map ( ( { name } ) => b ` $ $ self. $ $ .on_destroy.push(() => ${ ` $ $ unsubscribe_ ${ name . slice ( 1 ) } ` } ()); ` ) ;
. map ( ( { name } ) => b ` $ $ self. $ $ .on_destroy.push(() => ${ ` $ $ unsubscribe_ ${ name . slice ( 1 ) } ` } ()); ` ) ;
if ( has _definition ) {
/** @type {import('estree').Node | import('estree').Node[]} */
const reactive _declarations = [ ] ;
@ -364,14 +412,16 @@ export default function dom(component, options) {
const variable = component . var _lookup . get ( n ) ;
return variable && ( variable . export _name || variable . mutated || variable . reassigned ) ;
} ) ;
const condition = ! uses _rest _or _props && writable . length > 0 && renderer . dirty ( writable , true ) ;
const condition =
! uses _rest _or _props && writable . length > 0 && renderer . dirty ( writable , true ) ;
let statement = d . node ; // TODO remove label (use d.node.body) if it's not referenced
if ( condition )
statement = /** @type {import('estree').Statement} */ ( b ` if ( ${ condition } ) { ${ statement } } ` [ 0 ] ) ;
statement = /** @type {import('estree').Statement} */ (
b ` if ( ${ condition } ) { ${ statement } } ` [ 0 ]
) ;
if ( condition || uses _rest _or _props ) {
reactive _declarations . push ( statement ) ;
}
else {
} else {
fixed _reactive _declarations . push ( statement ) ;
}
} ) ;
@ -387,31 +437,36 @@ export default function dom(component, options) {
const unsubscribe = ` $ $ unsubscribe_ ${ name } ` ;
const subscribe = ` $ $ subscribe_ ${ name } ` ;
const i = renderer . context _lookup . get ( $name ) . index ;
return b ` let ${ $name } , ${ unsubscribe } = @noop, ${ subscribe } = () => ( ${ unsubscribe } (), ${ unsubscribe } = @subscribe( ${ name } , $ $ value => $ $ invalidate( ${ i } , ${ $name } = $ $ value)), ${ name } ) ` ;
return b ` let ${ $name } , ${ unsubscribe } = @noop, ${ subscribe } = () => ( ${ unsubscribe } (), ${ unsubscribe } = @subscribe( ${ name } , $ $ value => $ $ invalidate( ${ i } , ${ $name } = $ $ value)), ${ name } ) ` ;
}
return b ` let ${ $name } ; ` ;
return b ` let ${ $name } ; ` ;
} ) ;
/** @type {import('estree').Node[] | undefined} */
let unknown _props _check ;
if ( component . compile _options . dev && ! ( uses _props || uses _rest ) ) {
unknown _props _check = b `
const writable _props = [ $ { writable _props . map ( ( prop ) => x ` ' ${ prop . export _name } ' ` ) } ] ;
unknown _props _check = b `
const writable _props = [ $ { writable _props . map ( ( prop ) => x ` ' ${ prop . export _name } ' ` ) } ] ;
@ _Object . keys ( $$props ) . forEach ( key => {
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== '$$' && key !== 'slot' ) @ _console . warn ( \ ` < ${ component . tag } > was created with unknown prop ' \$ {key}' \` );
if ( ! ~ writable _props . indexOf ( key ) && key . slice ( 0 , 2 ) !== '$$' && key !== 'slot' ) @ _console . warn ( \ ` < ${
component . tag
} > was created with unknown prop '\${key}' \ ` );
} ) ;
` ;
}
const return _value = {
type : 'ArrayExpression' ,
elements : renderer . initial _context . map ( ( member ) => ( /** @type {import('estree').Expression} */ ( {
elements : renderer . initial _context . map (
( member ) =>
/** @type {import('estree').Expression} */ ( {
type : 'Identifier' ,
name : member . name
} ) ) )
} )
)
} ;
body . push ( b `
body . push ( b `
function $ { definition } ( $ { args } ) {
$ { injected . map ( ( name ) => b ` let ${ name } ; ` ) }
$ { injected . map ( ( name ) => b ` let ${ name } ; ` ) }
$ { rest }
@ -421,13 +476,17 @@ export default function dom(component, options) {
$ { resubscribable _reactive _store _unsubscribers }
$ { component . slots . size || component . compile _options . dev || uses _slots
? b ` let { $ $ slots: #slots = {}, $ $ scope } = $ $ props; `
: null }
$ { component . compile _options . dev &&
b ` @validate_slots(' ${ component . tag } ', #slots, [ ${ [ ... component . slots . keys ( ) ]
$ {
component . slots . size || component . compile _options . dev || uses _slots
? b ` let { $ $ slots: #slots = {}, $ $ scope } = $ $ props; `
: null
}
$ {
component . compile _options . dev &&
b ` @validate_slots(' ${ component . tag } ', #slots, [ ${ [ ... component . slots . keys ( ) ]
. map ( ( key ) => ` ' ${ key } ' ` )
. join ( ',' ) } ] ) ; ` }
. join ( ',' ) } ] ) ; `
}
$ { compute _slots }
$ { instance _javascript }
@ -435,44 +494,50 @@ export default function dom(component, options) {
$ { missing _props _check }
$ { unknown _props _check }
$ { renderer . binding _groups . size > 0 &&
b ` const $ $ binding_groups = [ ${ [ ... renderer . binding _groups . keys ( ) ] . map ( ( _ ) => x ` [] ` ) } ]; ` }
$ {
renderer . binding _groups . size > 0 &&
b ` const $ $ binding_groups = [ ${ [ ... renderer . binding _groups . keys ( ) ] . map ( ( _ ) => x ` [] ` ) } ]; `
}
$ { component . partly _hoisted }
$ { set && b ` $ $ self. $ $ set = ${ set } ; ` }
$ { set && b ` $ $ self. $ $ set = ${ set } ; ` }
$ { capture _state && b ` $ $ self. $ capture_state = ${ capture _state } ; ` }
$ { capture _state && b ` $ $ self. $ capture_state = ${ capture _state } ; ` }
$ { inject _state && b ` $ $ self. $ inject_state = ${ inject _state } ; ` }
$ { inject _state && b ` $ $ self. $ inject_state = ${ inject _state } ; ` }
$ { /* before reactive declarations */ props _inject }
$ { /* before reactive declarations */ props _inject }
$ { reactive _declarations . length > 0 &&
b `
$ {
reactive _declarations . length > 0 &&
b `
$$self . $$ . update = ( ) => {
$ { reactive _declarations }
} ;
` }
`
}
$ { fixed _reactive _declarations }
$ { uses _props && b ` $ $ props = @exclude_internal_props( $ $ props); ` }
$ { uses _props && b ` $ $ props = @exclude_internal_props( $ $ props); ` }
return $ { return _value } ;
}
` );
}
const prop _indexes = /** @type {import('estree').ObjectExpression} */ ( x ` {
const prop _indexes = /** @type {import('estree').ObjectExpression} */ (
x ` {
$ { props
. filter ( ( v ) => v . export _name && ! v . module )
. map ( ( v ) => p ` ${ v . export _name } : ${ renderer . context _lookup . get ( v . name ) . index } ` ) }
} ` );
. map ( ( v ) => p ` ${ v . export _name } : ${ renderer . context _lookup . get ( v . name ) . index } ` ) }
} `
) ;
let dirty ;
if ( renderer . context _overflow ) {
dirty = x ` [] ` ;
dirty = x ` [] ` ;
for ( let i = 0 ; i < renderer . context . length ; i += 31 ) {
dirty . elements . push ( x ` -1 ` ) ;
dirty . elements . push ( x ` -1 ` ) ;
}
}
const superclass = {
@ -482,23 +547,28 @@ export default function dom(component, options) {
const optional _parameters = [ ] ;
if ( should _add _css ) {
optional _parameters . push ( add _css ) ;
}
else if ( dirty ) {
optional _parameters . push ( x ` null ` ) ;
} else if ( dirty ) {
optional _parameters . push ( x ` null ` ) ;
}
if ( dirty ) {
optional _parameters . push ( dirty ) ;
}
const declaration = /** @type {import('estree').ClassDeclaration} */ ( b `
const declaration = /** @type {import('estree').ClassDeclaration} */ (
b `
class $ { name } extends $ { superclass } {
constructor ( options ) {
super ( $ { options . dev && 'options' } ) ;
@ init ( this , options , $ { definition } , $ { has _create _fragment ? 'create_fragment' : 'null' } , $ { not _equal } , $ { prop _indexes } , $ { optional _parameters } ) ;
$ { options . dev &&
b ` @dispatch_dev("SvelteRegisterComponent", { component: this, tagName: " ${ name . name } ", options, id: create_fragment.name }); ` }
@ init ( this , options , $ { definition } , $ {
has _create _fragment ? 'create_fragment' : 'null'
} , $ { not _equal } , $ { prop _indexes } , $ { optional _parameters } ) ;
$ {
options . dev &&
b ` @dispatch_dev("SvelteRegisterComponent", { component: this, tagName: " ${ name . name } ", options, id: create_fragment.name }); `
}
}
}
` [0]);
` [0]
) ;
push _array ( declaration . body . body , accessors ) ;
body . push ( declaration ) ;
if ( options . customElement ) {
@ -515,17 +585,23 @@ export default function dom(component, options) {
. filter ( ( accessor ) => ! writable _props . some ( ( prop ) => prop . export _name === accessor . key . name ) )
. map ( ( accessor ) => ` " ${ accessor . key . name } " ` )
. join ( ',' ) ;
const use _shadow _dom = component . component _options . customElement ? . shadow !== 'none' ? 'true' : 'false' ;
const use _shadow _dom =
component . component _options . customElement ? . shadow !== 'none' ? 'true' : 'false' ;
if ( component . component _options . customElement ? . tag ) {
body . push ( b ` @_customElements.define(" ${ component . component _options . customElement . tag } ", @create_custom_element( ${ name } , ${ JSON . stringify ( props _str ) } , [ ${ slots _str } ], [ ${ accessors _str } ], ${ use _shadow _dom } )); ` ) ;
}
else {
body . push ( b ` @create_custom_element( ${ name } , ${ JSON . stringify ( props _str ) } , [ ${ slots _str } ], [ ${ accessors _str } ], ${ use _shadow _dom } ); ` ) ;
body . push (
b ` @_customElements.define(" ${
component . component _options . customElement . tag
} " , @ create _custom _element ( $ { name } , $ { JSON . stringify (
props _str
) } , [ $ { slots _str } ] , [ $ { accessors _str } ] , $ { use _shadow _dom } ) ) ; `
) ;
} else {
body . push (
b ` @create_custom_element( ${ name } , ${ JSON . stringify (
props _str
) } , [ $ { slots _str } ] , [ $ { accessors _str } ] , $ { use _shadow _dom } ) ; `
) ;
}
}
return { js : flatten ( body ) , css } ;
}