Skip to content

Commit 0da2a99

Browse files
authored
Merge pull request #323 from sveltejs/gh-321
better error for unmatched closing tag
2 parents a8d1983 + 2efd532 commit 0da2a99

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/parse/state/tag.js

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export default function tag ( parser ) {
9090

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"message": "</div> attempted to close an element that was not open",
3+
"loc": {
4+
"line": 1,
5+
"column": 0
6+
},
7+
"pos": 0
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
</div>

0 commit comments

Comments
 (0)