Skip to content

Commit

Permalink
better error for unmatched closing tag (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Mar 1, 2017
1 parent a8d1983 commit 2efd532
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export default function tag ( parser ) {

// close any elements that don't have their own closing tags, e.g. <div><p></div>
while ( parent.name !== name ) {
if ( parent.type !== 'Element' ) parser.error( `</${name}> attempted to close an element that was not open`, start );

parent.end = start;
parser.stack.pop();

Expand Down
8 changes: 8 additions & 0 deletions test/parser/error-unmatched-closing-tag/error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"message": "</div> attempted to close an element that was not open",
"loc": {
"line": 1,
"column": 0
},
"pos": 0
}
1 change: 1 addition & 0 deletions test/parser/error-unmatched-closing-tag/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
</div>

0 comments on commit 2efd532

Please sign in to comment.