diff --git a/src/compiler/compile/render_ssr/handlers/Element.ts b/src/compiler/compile/render_ssr/handlers/Element.ts index 0cd101df72..8b64361c4f 100644 --- a/src/compiler/compile/render_ssr/handlers/Element.ts +++ b/src/compiler/compile/render_ssr/handlers/Element.ts @@ -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)}"`; } diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 1ae1ae1d12..4bc06f4351 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -134,7 +134,7 @@ export function get_store_value(store: Readable): 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}"`}`}`; } diff --git a/test/runtime/samples/attribute-false/_config.js b/test/runtime/samples/attribute-false/_config.js index 0f37392806..9fd08a2a48 100644 --- a/test/runtime/samples/attribute-false/_config.js +++ b/test/runtime/samples/attribute-false/_config.js @@ -1,5 +1,3 @@ export default { - skip_if_ssr: true, - html: `
`, }; diff --git a/test/runtime/samples/attribute-null-classname-no-style/_config.js b/test/runtime/samples/attribute-null-classname-no-style/_config.js index e2098430e4..4a78b680ef 100644 --- a/test/runtime/samples/attribute-null-classname-no-style/_config.js +++ b/test/runtime/samples/attribute-null-classname-no-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName: "testClassName" }, diff --git a/test/runtime/samples/attribute-null-classname-with-style/_config.js b/test/runtime/samples/attribute-null-classname-with-style/_config.js index 635dd058ca..3ebc593b5d 100644 --- a/test/runtime/samples/attribute-null-classname-with-style/_config.js +++ b/test/runtime/samples/attribute-null-classname-with-style/_config.js @@ -1,15 +1,8 @@ export default { - skip_if_ssr: true, - - props: { - testName: "testClassName" - }, - - html: `
`, + html: `
`, 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'); } }; diff --git a/test/runtime/samples/attribute-null-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-classnames-no-style/_config.js index 6a734efff5..917cf565c0 100644 --- a/test/runtime/samples/attribute-null-classnames-no-style/_config.js +++ b/test/runtime/samples/attribute-null-classnames-no-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName1: "test1", testName2: "test2", diff --git a/test/runtime/samples/attribute-null-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-classnames-with-style/_config.js index 22f7a4d7e2..5762f628fb 100644 --- a/test/runtime/samples/attribute-null-classnames-with-style/_config.js +++ b/test/runtime/samples/attribute-null-classnames-with-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName1: "test1", testName2: "test2", diff --git a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js index e2098430e4..4a78b680ef 100644 --- a/test/runtime/samples/attribute-null-func-classname-no-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classname-no-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName: "testClassName" }, diff --git a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js index 635dd058ca..1ed43d05b9 100644 --- a/test/runtime/samples/attribute-null-func-classname-with-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classname-with-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName: "testClassName" }, diff --git a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js index 6a734efff5..917cf565c0 100644 --- a/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classnames-no-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName1: "test1", testName2: "test2", diff --git a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js index 22f7a4d7e2..5762f628fb 100644 --- a/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js +++ b/test/runtime/samples/attribute-null-func-classnames-with-style/_config.js @@ -1,6 +1,4 @@ export default { - skip_if_ssr: true, - props: { testName1: "test1", testName2: "test2", diff --git a/test/runtime/samples/attribute-null/_config.js b/test/runtime/samples/attribute-null/_config.js index 938d525cf6..ae2f0a8af6 100644 --- a/test/runtime/samples/attribute-null/_config.js +++ b/test/runtime/samples/attribute-null/_config.js @@ -1,5 +1,3 @@ export default { - skip_if_ssr: true, - html: `
`, }; diff --git a/test/runtime/samples/attribute-undefined/_config.js b/test/runtime/samples/attribute-undefined/_config.js index 938d525cf6..ae2f0a8af6 100644 --- a/test/runtime/samples/attribute-undefined/_config.js +++ b/test/runtime/samples/attribute-undefined/_config.js @@ -1,5 +1,3 @@ export default { - skip_if_ssr: true, - html: `
`, };