From 5ba51be341aa26c730ba54e9319b0c4acda5dc06 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 4 Jan 2017 11:49:18 -0500 Subject: [PATCH] dont use properties when setting element attributes (fixes #233) --- .../visitors/attributes/addElementAttributes.js | 2 +- test/generator/svg-class/_config.js | 14 ++++++++++++++ test/generator/svg-class/main.html | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/generator/svg-class/_config.js create mode 100644 test/generator/svg-class/main.html diff --git a/src/generators/dom/visitors/attributes/addElementAttributes.js b/src/generators/dom/visitors/attributes/addElementAttributes.js index 96bcd74998..490d330348 100644 --- a/src/generators/dom/visitors/attributes/addElementAttributes.js +++ b/src/generators/dom/visitors/attributes/addElementAttributes.js @@ -6,7 +6,7 @@ import flattenReference from '../../../../utils/flattenReference.js'; export default function addElementAttributes ( generator, node, local ) { node.attributes.forEach( attribute => { if ( attribute.type === 'Attribute' ) { - let metadata = generator.current.namespace ? null : attributeLookup[ attribute.name ]; + let metadata = local.namespace ? null : attributeLookup[ attribute.name ]; if ( metadata && metadata.appliesTo && !~metadata.appliesTo.indexOf( node.name ) ) metadata = null; let dynamic = false; diff --git a/test/generator/svg-class/_config.js b/test/generator/svg-class/_config.js new file mode 100644 index 0000000000..d801f4d602 --- /dev/null +++ b/test/generator/svg-class/_config.js @@ -0,0 +1,14 @@ +// this looks like another JSDOM quirk — svg.className = 'foo' behaves +// differently from browsers. So this test succeeds even when it should fail +export default { + html: ``, + + test ( assert, component, target ) { + const svg = target.querySelector( 'svg' ); + + assert.equal( svg.namespaceURI, 'http://www.w3.org/2000/svg' ); + assert.equal( svg.getAttribute( 'class' ), 'foo' ); + + component.teardown(); + } +}; diff --git a/test/generator/svg-class/main.html b/test/generator/svg-class/main.html new file mode 100644 index 0000000000..10c023ee88 --- /dev/null +++ b/test/generator/svg-class/main.html @@ -0,0 +1 @@ +