Skip to content

Commit a47a679

Browse files
committed
replace all invalid characters in attribute names when creating variables (fixes #470)
1 parent c54bebb commit a47a679

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/generators/dom/visitors/Element/Attribute.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function visitAttribute ( generator, block, state, node, attribut
4343
);
4444
}
4545

46-
const last = `last_${state.parentNode}_${name.replace( /-/g, '_')}`;
46+
const last = `last_${state.parentNode}_${name.replace( /[^a-zA-Z_$]/g, '_')}`;
4747
block.builders.create.addLine( `var ${last} = ${value};` );
4848

4949
const isSelectValueAttribute = name === 'value' && state.parentNodeName === 'select';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default {
2+
data: { foo: 'bar' },
3+
4+
html: `
5+
<svg>
6+
<use xlink:href="#bar"/>
7+
</svg>
8+
`,
9+
10+
test ( assert, component, target ) {
11+
const use = target.querySelector( 'use' );
12+
assert.equal( use.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ), '#bar' );
13+
}
14+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<svg>
2+
<use xlink:href="#{{foo}}"/>
3+
</svg>

0 commit comments

Comments
 (0)