failing SSR test, plus some adjacent changes

pull/3330/head
Richard Harris 5 years ago
parent 886961b927
commit c53563b207

@ -140,8 +140,7 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
} else if (attribute.chunks.length === 1 && attribute.chunks[0].type !== 'Text') {
const { name } = attribute;
const snippet = snip(attribute.chunks[0]);
opening_tag += '${(v => v == null ? "" : ` ' + name + '="${@escape(' + snippet + ')}"`)(' + snippet + ')}';
opening_tag += '${@add_attribute("' + name + '", ' + snippet + ')}';
} else {
opening_tag += ` ${attribute.name}="${stringify_attribute(attribute, true)}"`;
}

@ -134,7 +134,7 @@ export function get_store_value<T>(store: Readable<T>): T | undefined {
}
export function add_attribute(name, value) {
if (!value) return '';
if (value == null) return '';
return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(value) : `"${value}"`}`}`;
}

@ -1,5 +1,3 @@
export default {
skip_if_ssr: true,
html: `<div class="false"></div>`,
};

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName: "testClassName"
},

@ -1,15 +1,8 @@
export default {
skip_if_ssr: true,
props: {
testName: "testClassName"
},
html: `<div class="testClassName svelte-x1o6ra"></div>`,
html: `<div class=" svelte-x1o6ra"></div>`,
test({ assert, component, target }) {
const div = target.querySelector('div');
assert.equal(div.className, 'testClassName svelte-x1o6ra');
component.testName = null;
assert.equal(div.className, ' svelte-x1o6ra');
@ -40,5 +33,8 @@ export default {
component.testName = '';
assert.equal(div.className, ' svelte-x1o6ra');
component.testName = 'testClassName';
assert.equal(div.className, 'testClassName svelte-x1o6ra');
}
};

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName1: "test1",
testName2: "test2",

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName1: "test1",
testName2: "test2",

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName: "testClassName"
},

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName: "testClassName"
},

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName1: "test1",
testName2: "test2",

@ -1,6 +1,4 @@
export default {
skip_if_ssr: true,
props: {
testName1: "test1",
testName2: "test2",

@ -1,5 +1,3 @@
export default {
skip_if_ssr: true,
html: `<div></div>`,
};

@ -1,5 +1,3 @@
export default {
skip_if_ssr: true,
html: `<div></div>`,
};

Loading…
Cancel
Save