Skip to content

Commit

Permalink
Merge pull request #225 from sveltejs/gh-224
Browse files Browse the repository at this point in the history
provide useful feedback on encountering void element closing tag
  • Loading branch information
Rich-Harris authored Dec 24, 2016
2 parents 91551b9 + fc977a2 commit 620b9ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default function tag ( parser ) {
parser.allowWhitespace();

if ( isClosingTag ) {
if ( voidElementNames.test( name ) ) {
parser.error( `<${name}> is a void element and cannot have children, or a closing tag`, start );
}

if ( !parser.eat( '>' ) ) parser.error( `Expected '>'` );

const element = parser.current();
Expand Down
8 changes: 8 additions & 0 deletions test/parser/error-void-closing/error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"message": "<input> is a void element and cannot have children, or a closing tag",
"loc": {
"line": 1,
"column": 23
},
"pos": 23
}
1 change: 1 addition & 0 deletions test/parser/error-void-closing/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input>this is illegal!</input>

0 comments on commit 620b9ae

Please sign in to comment.