Skip to content

Commit

Permalink
Merge pull request #241 from sveltejs/gh-233
Browse files Browse the repository at this point in the history
dont use properties when setting <svg> element attributes
  • Loading branch information
Rich-Harris authored Jan 4, 2017
2 parents 16a456b + 5ba51be commit 5755334
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions test/generator/svg-class/_config.js
Original file line number Diff line number Diff line change
@@ -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: `<svg class='foo'></svg>`,

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();
}
};
1 change: 1 addition & 0 deletions test/generator/svg-class/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<svg class='foo'></svg>

0 comments on commit 5755334

Please sign in to comment.