diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 756bf7e0f5..c08123b8c3 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -475,9 +475,11 @@ export default function dom( constructor(options) { super(); - ${css.code && b`this.shadowRoot.innerHTML = \`\`;`} + const add_css = ${css.code + ? (b`() => this.shadowRoot.innerHTML = \`\`;`) + : x`@noop`} - @init(this, { target: this.shadowRoot, props: @attribute_to_object(this.attributes) }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty}); + @init(this, { target: this.shadowRoot, props: @attribute_to_object(this.attributes) }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${add_css}, ${dirty}); ${dev_props_check} @@ -528,7 +530,7 @@ export default function dom( class ${name} extends ${superclass} { constructor(options) { super(${options.dev && 'options'}); - @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : null}, ${dirty}); + @init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${should_add_css ? add_css : x`@noop`}, ${dirty}); ${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`} ${dev_props_check} diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index ef3aa29318..4524a5dba9 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -130,7 +130,7 @@ export function init(component, options, instance, create_fragment, not_equal, p let ready = false; - add_css && add_css($$.customStyleTag); + add_css($$.customStyleTag); $$.ctx = instance ? instance(component, prop_values, (i, ret, ...rest) => {