@@ -50,11 +50,8 @@ export default function dom(
50
50
51
51
if ( should_add_css ) {
52
52
body . push ( b `
53
- function ${ add_css } () {
54
- var style = @element("style");
55
- style.id = "${ component . stylesheet . id } -style";
56
- style.textContent = "${ styles } ";
57
- @append(@_document.head, style);
53
+ function ${ add_css } (target) {
54
+ @append_styles(target, "${ component . stylesheet . id } ", "${ styles } ");
58
55
}
59
56
` ) ;
60
57
}
@@ -486,7 +483,7 @@ export default function dom(
486
483
487
484
${ css . code && b `this.shadowRoot.innerHTML = \`<style>${ css . code . replace ( / \\ / g, '\\\\' ) } ${ options . dev ? `\n/*# sourceMappingURL=${ css . map . toUrl ( ) } */` : '' } </style>\`;` }
488
485
489
- @init(this, { target: this.shadowRoot, props: ${ init_props } , customElement: true }, ${ definition } , ${ has_create_fragment ? 'create_fragment' : 'null' } , ${ not_equal } , ${ prop_indexes } , ${ dirty } );
486
+ @init(this, { target: this.shadowRoot, props: ${ init_props } , customElement: true }, ${ definition } , ${ has_create_fragment ? 'create_fragment' : 'null' } , ${ not_equal } , ${ prop_indexes } , null, ${ dirty } );
490
487
491
488
${ dev_props_check }
492
489
@@ -533,12 +530,21 @@ export default function dom(
533
530
name : options . dev ? '@SvelteComponentDev' : '@SvelteComponent'
534
531
} ;
535
532
533
+ const optional_parameters = [ ] ;
534
+ if ( should_add_css ) {
535
+ optional_parameters . push ( add_css ) ;
536
+ } else if ( dirty ) {
537
+ optional_parameters . push ( x `null` ) ;
538
+ }
539
+ if ( dirty ) {
540
+ optional_parameters . push ( dirty ) ;
541
+ }
542
+
536
543
const declaration = b `
537
544
class ${ name } extends ${ superclass } {
538
545
constructor(options) {
539
546
super(${ options . dev && 'options' } );
540
- ${ should_add_css && b `if (!@_document.getElementById("${ component . stylesheet . id } -style")) ${ add_css } ();` }
541
- @init(this, options, ${ definition } , ${ has_create_fragment ? 'create_fragment' : 'null' } , ${ not_equal } , ${ prop_indexes } , ${ dirty } );
547
+ @init(this, options, ${ definition } , ${ has_create_fragment ? 'create_fragment' : 'null' } , ${ not_equal } , ${ prop_indexes } , ${ optional_parameters } );
542
548
${ options . dev && b `@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${ name . name } ", options, id: create_fragment.name });` }
543
549
544
550
${ dev_props_check }
0 commit comments