slightly improve output size by refactoring add_css method

pull/5639/head
Ivan Hofer 5 years ago
parent 4f9a15eced
commit b0cacd7f25

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

@ -4,7 +4,7 @@ export function appendStyleIfNotPresent(
target: Element = document.head,
styleSheetId: string,
styles: string,
styleId:string = styleSheetId + '-style') {
styleId:string = `svelte-${styleSheetId}-style`) {
if (!target.querySelector('#' + styleId)) {
const style = element('style');
style.id = styleId;

Loading…
Cancel
Save