fix tests for 'stylesTarget'

pull/5870/head
Ivan Hofer 6 years ago
parent 3c172aebd2
commit 6be665216f

@ -2,6 +2,7 @@
import { import {
SvelteComponent, SvelteComponent,
append, append,
append_styles,
attr, attr,
detach, detach,
element, element,
@ -13,11 +14,8 @@ import {
text text
} from "svelte/internal"; } from "svelte/internal";
function add_css() { function add_css(options) {
var style = element("style"); append_styles(options, "1a7i8ec", "p.svelte-1a7i8ec{color:red}");
style.id = "svelte-1a7i8ec-style";
style.textContent = "p.svelte-1a7i8ec{color:red}";
append(document.head, style);
} }
function create_fragment(ctx) { function create_fragment(ctx) {
@ -58,7 +56,7 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent { class Component extends SvelteComponent {
constructor(options) { constructor(options) {
super(); super();
if (!document.getElementById("svelte-1a7i8ec-style")) add_css(); add_css(options);
init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 }); init(this, options, instance, create_fragment, safe_not_equal, { foo: 0 });
} }
} }

@ -1,7 +1,7 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append_styles,
attr, attr,
detach, detach,
element, element,
@ -11,11 +11,8 @@ import {
safe_not_equal safe_not_equal
} from "svelte/internal"; } from "svelte/internal";
function add_css() { function add_css(options) {
var style = element("style"); append_styles(options, "1slhpfn", "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}");
style.id = "svelte-1slhpfn-style";
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}";
append(document.head, style);
} }
function create_fragment(ctx) { function create_fragment(ctx) {
@ -41,7 +38,7 @@ function create_fragment(ctx) {
class Component extends SvelteComponent { class Component extends SvelteComponent {
constructor(options) { constructor(options) {
super(); super();
if (!document.getElementById("svelte-1slhpfn-style")) add_css(); add_css(options);
init(this, options, null, create_fragment, safe_not_equal, {}); init(this, options, null, create_fragment, safe_not_equal, {});
} }
} }

@ -5,7 +5,7 @@ const b64dec = s => Buffer.from(s, 'base64').toString();
export async function test({ assert, css, js }) { export async function test({ assert, css, js }) {
// We check that the css source map embedded in the js is accurate // We check that the css source map embedded in the js is accurate
const match = js.code.match(/\tstyle\.textContent = "(.*?)(?:\\n\/\*# sourceMappingURL=data:(.*?);charset=(.*?);base64,(.*?) \*\/)?";\n/); const match = js.code.match(/\tappend_styles\(options, ".{6}", "(.*?)(?:\\n\/\*# sourceMappingURL=data:(.*?);charset=(.*?);base64,(.*?) \*\/)?"\);\n/);
assert.notEqual(match, null); assert.notEqual(match, null);
const [mimeType, encoding, cssMapBase64] = match.slice(2); const [mimeType, encoding, cssMapBase64] = match.slice(2);

Loading…
Cancel
Save