mirror of
https://github.com/sveltejs/svelte.git
synced 2024-11-30 17:00:40 +01:00
Merge pull request #517 from sveltejs/gh-516
Replace invalid characters in element names when creating variables
This commit is contained in:
commit
a09605264f
@ -34,7 +34,7 @@ export default function visitElement ( generator, block, state, node ) {
|
||||
return visitComponent( generator, block, state, node );
|
||||
}
|
||||
|
||||
const name = block.getUniqueName( node.name );
|
||||
const name = block.getUniqueName( node.name.replace( /[^a-zA-Z_$]/g, '_' ) );
|
||||
|
||||
const childState = Object.assign( {}, state, {
|
||||
isTopLevel: false,
|
||||
@ -136,4 +136,4 @@ function getRenderStatement ( generator, namespace, name ) {
|
||||
}
|
||||
|
||||
return `${generator.helper( 'createElement' )}( '${name}' )`;
|
||||
}
|
||||
}
|
||||
|
5
test/runtime/samples/element-invalid-name/_config.js
Normal file
5
test/runtime/samples/element-invalid-name/_config.js
Normal file
@ -0,0 +1,5 @@
|
||||
export default {
|
||||
html: `
|
||||
<foo-bar>Hello</foo-bar>
|
||||
`
|
||||
}
|
1
test/runtime/samples/element-invalid-name/main.html
Normal file
1
test/runtime/samples/element-invalid-name/main.html
Normal file
@ -0,0 +1 @@
|
||||
<foo-bar>Hello</foo-bar>
|
Loading…
Reference in New Issue
Block a user