fix more tests

pull/4297/head
Tan Li Hau 6 years ago
parent c8232107a6
commit 6fb365e735

@ -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)];

@ -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

@ -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);
}

@ -11,6 +11,9 @@ export default {
html: `<p>potato</p>`,
before_test() {
count = 0;
},
test({ assert, component, target }) {
assert.equal(count, 1);

@ -17,6 +17,11 @@ export default {
html: `<p>potato</p>`,
before_test() {
count_a = 0;
count_b = 0;
},
test({ assert, component, target }) {
assert.equal(count_a, 1);
assert.equal(count_b, 0);

@ -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;
},
};

@ -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;
}
};

@ -1,9 +1,14 @@
export default {
skip_if_ssr: true,
html: `
<div>foo</div>
<div>foo<div>foo</div></div>
`,
ssrHtml: `
<noscript>foo</noscript>
<div>foo<noscript>foo</noscript></div>
<div>foo<div>foo<noscript>foo</noscript></div></div>
`,
};

Loading…
Cancel
Save