diff --git a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts index 85f252f57e..05bdae973a 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts @@ -55,13 +55,9 @@ export default class AttributeWrapper { const element = this.parent; const name = fix_attribute_casing(this.node.name); - const metadata = this.get_metadata(); - const is_indirectly_bound_value = this.is_indirectly_bound_value(); - const property_name = is_indirectly_bound_value - ? '__value' - : metadata && metadata.property_name; + const property_name = this.get_property_name(); // xlink is a special case... we could maybe extend this to generic // namespaced attributes but I'm not sure that's applicable in @@ -185,6 +181,14 @@ export default class AttributeWrapper { } } + get_property_name() { + const metadata = this.get_metadata(); + const is_indirectly_bound_value = this.is_indirectly_bound_value(); + return is_indirectly_bound_value + ? '__value' + : metadata && metadata.property_name; + } + get_metadata() { if (this.parent.node.namespace) return null; const metadata = attribute_lookup[fix_attribute_casing(this.node.name)]; diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index e9fac59869..71e5260a9e 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -405,7 +405,7 @@ export default class ElementWrapper extends Wrapper { get_render_statement(block: Block) { const { name, namespace } = this.node; - if (namespace === 'http://www.w3.org/2000/svg') { + if (namespace === namespaces.svg) { return x`@svg_element("${name}")`; } @@ -422,9 +422,9 @@ export default class ElementWrapper extends Wrapper { } get_claim_statement(nodes: Identifier) { - const attributes = this.node.attributes - .filter((attr) => attr.type === 'Attribute') - .map((attr) => p`${fix_attribute_casing(attr.name)}: true`); + const attributes = this.attributes + .filter((attr) => attr.node.type === 'Attribute' && !attr.get_property_name()) + .map((attr) => p`${fix_attribute_casing(attr.node.name)}: true`); const name = this.node.namespace ? this.node.name diff --git a/test/runtime/index.js b/test/runtime/index.js index c02226c14a..885423286c 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -146,8 +146,6 @@ describe("runtime", () => { throw err; } - if (config.before_test) config.before_test(); - // Put things we need on window for testing window.SvelteComponent = SvelteComponent; @@ -160,10 +158,11 @@ describe("runtime", () => { const SsrSvelteComponent = require(`./samples/${dir}/main.svelte`).default; const { html } = SsrSvelteComponent.render(config.props); target.innerHTML = html; - delete compileOptions.generate; } + if (config.before_test) config.before_test(); + const warnings = []; const warn = console.warn; console.warn = warning => { @@ -193,9 +192,7 @@ describe("runtime", () => { throw new Error("Received unexpected warnings"); } - if (hydrate && config.ssrHtml) { - assert.htmlEqual(target.innerHTML, config.ssrHtml); - } else if (config.html) { + if (config.html) { assert.htmlEqual(target.innerHTML, config.html); } diff --git a/test/runtime/samples/if-block-conservative-update/_config.js b/test/runtime/samples/if-block-conservative-update/_config.js index a71166ef81..aef6ac9538 100644 --- a/test/runtime/samples/if-block-conservative-update/_config.js +++ b/test/runtime/samples/if-block-conservative-update/_config.js @@ -11,6 +11,9 @@ export default { html: `

potato

`, + before_test() { + count = 0; + }, test({ assert, component, target }) { assert.equal(count, 1); diff --git a/test/runtime/samples/if-block-else-conservative-update/_config.js b/test/runtime/samples/if-block-else-conservative-update/_config.js index 5c90d2ad3a..5c8ed83eed 100644 --- a/test/runtime/samples/if-block-else-conservative-update/_config.js +++ b/test/runtime/samples/if-block-else-conservative-update/_config.js @@ -17,6 +17,11 @@ export default { html: `

potato

`, + before_test() { + count_a = 0; + count_b = 0; + }, + test({ assert, component, target }) { assert.equal(count_a, 1); assert.equal(count_b, 0); diff --git a/test/runtime/samples/lifecycle-render-order-for-children/_config.js b/test/runtime/samples/lifecycle-render-order-for-children/_config.js index 033b593aea..976d6eb55b 100644 --- a/test/runtime/samples/lifecycle-render-order-for-children/_config.js +++ b/test/runtime/samples/lifecycle-render-order-for-children/_config.js @@ -2,7 +2,9 @@ import order from './order.js'; export default { skip_if_ssr: true, - + before_test() { + order.length = 0; + }, test({ assert, component, target, compileOptions }) { if (compileOptions.hydratable) { assert.deepEqual(order, [ @@ -44,6 +46,5 @@ export default { ]); } - order.length = 0; }, }; diff --git a/test/runtime/samples/lifecycle-render-order/_config.js b/test/runtime/samples/lifecycle-render-order/_config.js index 5080973cef..2bbab7a838 100644 --- a/test/runtime/samples/lifecycle-render-order/_config.js +++ b/test/runtime/samples/lifecycle-render-order/_config.js @@ -3,6 +3,9 @@ import order from './order.js'; export default { skip_if_ssr: true, + before_test() { + order.length = 0; + }, test({ assert }) { assert.deepEqual(order, [ 'beforeUpdate', @@ -10,7 +13,5 @@ export default { 'onMount', 'afterUpdate' ]); - - order.length = 0; } }; diff --git a/test/runtime/samples/noscript-removal/_config.js b/test/runtime/samples/noscript-removal/_config.js index 35bdcefd96..657cff8870 100644 --- a/test/runtime/samples/noscript-removal/_config.js +++ b/test/runtime/samples/noscript-removal/_config.js @@ -1,9 +1,14 @@ export default { - skip_if_ssr: true, - html: `
foo
foo
foo
`, + ssrHtml: ` + + +
foo
+ +
foo
foo
+ `, };