fix `add_css` to allow custom stle hashes

pull/5870/head
Ivan Hofer 5 years ago
parent eb6fd8f9a4
commit 7e5a1ec50d

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

@ -115,14 +115,13 @@ function init_hydrate(target: NodeEx) {
export function append_styles( export function append_styles(
target: Node, target: Node,
styleSheetId: string, styleSheetId: string,
styles: string, styles: string
styleId: string = `svelte-${styleSheetId}-style`
) { ) {
const appendStylesTo = get_root_for_styles(target); const appendStylesTo = get_root_for_styles(target);
if (!appendStylesTo?.querySelector('#' + styleId)) { if (!appendStylesTo?.querySelector(`#${styleSheetId}`)) {
const style = element('style'); const style = element('style');
style.id = styleId; style.id = styleSheetId;
style.textContent = styles; style.textContent = styles;
append(appendStylesTo, style); append(appendStylesTo, style);
} }

Loading…
Cancel
Save