From 83d5fe8256870f2f6b4fbc3daf78ce1b0ba36b6b Mon Sep 17 00:00:00 2001 From: Ivan Hofer Date: Thu, 12 Nov 2020 07:32:45 +0100 Subject: [PATCH] fix tests using new add_css methods --- .../collapses-text-around-comments/expected.js | 11 +++++------ test/js/samples/css-media-query/expected.js | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/test/js/samples/collapses-text-around-comments/expected.js b/test/js/samples/collapses-text-around-comments/expected.js index 67335ce246..e4c120b638 100644 --- a/test/js/samples/collapses-text-around-comments/expected.js +++ b/test/js/samples/collapses-text-around-comments/expected.js @@ -1,7 +1,9 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, + addCssToComponent, append, + appendStyleIfNotPresent, attr, detach, element, @@ -13,11 +15,8 @@ import { text } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1a7i8ec-style"; - style.textContent = "p.svelte-1a7i8ec{color:red}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1a7i8ec-style", "p.svelte-1a7i8ec{color:red}"); } function create_fragment(ctx) { @@ -58,7 +57,7 @@ function instance($$self, $$props, $$invalidate) { class Component extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); + addCssToComponent(this, add_css, options); init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); } } diff --git a/test/js/samples/css-media-query/expected.js b/test/js/samples/css-media-query/expected.js index f477670059..b8e1531bf1 100644 --- a/test/js/samples/css-media-query/expected.js +++ b/test/js/samples/css-media-query/expected.js @@ -1,7 +1,8 @@ /* generated by Svelte vX.Y.Z */ import { SvelteComponent, - append, + addCssToComponent, + appendStyleIfNotPresent, attr, detach, element, @@ -11,11 +12,8 @@ import { safe_not_equal } from "svelte/internal"; -function add_css() { - var style = element("style"); - style.id = "svelte-1slhpfn-style"; - style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"; - append(document.head, style); +function add_css(customStyleTag) { + appendStyleIfNotPresent(customStyleTag || document.head, "svelte-1slhpfn-style", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}"); } function create_fragment(ctx) { @@ -41,7 +39,7 @@ function create_fragment(ctx) { class Component extends SvelteComponent { constructor(options) { super(); - if (!document.getElementById("svelte-1slhpfn-style")) add_css(); + addCssToComponent(this, add_css, options); init(this, options, null, create_fragment, safe_not_equal, {}); } }