Merge pull request #471 from sveltejs/gh-470

replace all invalid characters in attribute names when creating variables
pull/477/head
Rich Harris 8 years ago committed by GitHub
commit d7320ba9fd

@ -43,7 +43,7 @@ export default function visitAttribute ( generator, block, state, node, attribut
);
}
const last = `last_${state.parentNode}_${name.replace( /-/g, '_')}`;
const last = `last_${state.parentNode}_${name.replace( /[^a-zA-Z_$]/g, '_')}`;
block.builders.create.addLine( `var ${last} = ${value};` );
const isSelectValueAttribute = name === 'value' && state.parentNodeName === 'select';

@ -0,0 +1,14 @@
export default {
data: { foo: 'bar' },
html: `
<svg>
<use xlink:href="#bar"/>
</svg>
`,
test ( assert, component, target ) {
const use = target.querySelector( 'use' );
assert.equal( use.getAttributeNS( 'http://www.w3.org/1999/xlink', 'href' ), '#bar' );
}
};

@ -0,0 +1,3 @@
<svg>
<use xlink:href="#{{foo}}"/>
</svg>

After

Width:  |  Height:  |  Size: 42 B

Loading…
Cancel
Save