From e5ecca32c736c412513273b526b01c27404978c5 Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Mon, 28 Jun 2021 17:49:56 +0200 Subject: [PATCH] only output `null` as value for `append_styles` in `init` function if `dirty` is set --- src/compiler/compile/render_dom/index.ts | 10 ++++++++++ src/runtime/internal/Component.ts | 10 +--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 4eb13e1eff..b57ea867b9 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -529,6 +529,16 @@ export default function dom( name: options.dev ? '@SvelteComponentDev' : '@SvelteComponent' }; + const optionalParameters = []; + if (should_add_css) { + optionalParameters.push(add_css); + } else if (dirty) { + optionalParameters.push(x`null`); + } + if (dirty) { + optionalParameters.push(dirty); + } + const declaration = b` class ${name} extends ${superclass} { constructor(options) { diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 65440c52cb..e706928af3 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -104,15 +104,7 @@ function make_dirty(component, i) { component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31)); } -let append_styles; -export function set_append_styles(append_styles_fn) { - append_styles = function (root) { - append_styles_fn(root); - append_styles = null; - }; -} - -export function init(component, options, instance, create_fragment, not_equal, props, _append_styles_legacy, dirty = [-1]) { +export function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) { const parent_component = current_component; set_current_component(component);