diff --git a/src/compiler/compile/render_dom/index.ts b/src/compiler/compile/render_dom/index.ts index 050b23abc3..a32db46078 100644 --- a/src/compiler/compile/render_dom/index.ts +++ b/src/compiler/compile/render_dom/index.ts @@ -44,8 +44,8 @@ export default function dom( if (should_add_css) { body.push(b` - function ${add_css}(customStyleTag) { - @appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); + function ${add_css}(target) { + @appendStyleIfNotPresent(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); } `); } diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index 8be0b7cb19..871d248969 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -102,7 +102,7 @@ export function addCssToComponent(component, add_css, options) { component.$$ = { customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag }; - add_css(component.$$.customStyleTag); + add_css(component.$$.customStyleTag || document.head); } export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) { diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index af35105b11..08070c514a 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,7 +1,7 @@ import { has_prop } from './utils'; export function appendStyleIfNotPresent( - target: Element = document.head, + target: Element, styleSheetId: string, styles: string, styleId:string = `svelte-${styleSheetId}-style`) {