move document.head to addCssToComponent method

pull/5639/head
Ivan Hofer 5 years ago
parent 5c3038ccae
commit 6d85265858

@ -44,8 +44,8 @@ export default function dom(
if (should_add_css) { if (should_add_css) {
body.push(b` body.push(b`
function ${add_css}(customStyleTag) { function ${add_css}(target) {
@appendStyleIfNotPresent(customStyleTag, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}"); @appendStyleIfNotPresent(target, "${component.stylesheet.id.replace('svelte-', '')}", "${styles}");
} }
`); `);
} }

@ -102,7 +102,7 @@ export function addCssToComponent(component, add_css, options) {
component.$$ = { component.$$ = {
customStyleTag: options.customStyleTag || current_component && current_component.$$.customStyleTag 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]) { export function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {

@ -1,7 +1,7 @@
import { has_prop } from './utils'; import { has_prop } from './utils';
export function appendStyleIfNotPresent( export function appendStyleIfNotPresent(
target: Element = document.head, target: Element,
styleSheetId: string, styleSheetId: string,
styles: string, styles: string,
styleId:string = `svelte-${styleSheetId}-style`) { styleId:string = `svelte-${styleSheetId}-style`) {

Loading…
Cancel
Save