Skip to content

Commit

Permalink
Merge pull request #517 from sveltejs/gh-516
Browse files Browse the repository at this point in the history
Replace invalid characters in element names when creating variables
  • Loading branch information
Conduitry authored Apr 20, 2017
2 parents 3dafc39 + 2bc223a commit a096052
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/generators/dom/visitors/Element/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -136,4 +136,4 @@ function getRenderStatement ( generator, namespace, name ) {
}

return `${generator.helper( 'createElement' )}( '${name}' )`;
}
}
5 changes: 5 additions & 0 deletions test/runtime/samples/element-invalid-name/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
html: `
<foo-bar>Hello</foo-bar>
`
}
1 change: 1 addition & 0 deletions test/runtime/samples/element-invalid-name/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<foo-bar>Hello</foo-bar>

0 comments on commit a096052

Please sign in to comment.