Skip to content

Commit a096052

Browse files
authored
Merge pull request #517 from sveltejs/gh-516
Replace invalid characters in element names when creating variables
2 parents 3dafc39 + 2bc223a commit a096052

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default function visitElement ( generator, block, state, node ) {
3434
return visitComponent( generator, block, state, node );
3535
}
3636

37-
const name = block.getUniqueName( node.name );
37+
const name = block.getUniqueName( node.name.replace( /[^a-zA-Z_$]/g, '_' ) );
3838

3939
const childState = Object.assign( {}, state, {
4040
isTopLevel: false,
@@ -136,4 +136,4 @@ function getRenderStatement ( generator, namespace, name ) {
136136
}
137137

138138
return `${generator.helper( 'createElement' )}( '${name}' )`;
139-
}
139+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
html: `
3+
<foo-bar>Hello</foo-bar>
4+
`
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<foo-bar>Hello</foo-bar>

0 commit comments

Comments
 (0)