-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] script style end parsing (#6511)
* update script end tag parsing to allow whitespace after tagname * update style end tag parsing to allow for whitespace after tag name * handle no closing match for script and style for eof and non-eof failures * cleaning up script and style end tag parsing Co-authored-by: pngwn <[email protected]>
- Loading branch information
Showing
13 changed files
with
331 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"code": "unclosed-script", | ||
"message": "<script> must have a closing tag", | ||
"start": { | ||
"line": 3, | ||
"column": 22, | ||
"character": 32 | ||
}, | ||
"pos": 32 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script> | ||
<h1>Hello {name}!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"code": "unclosed-style", | ||
"message": "<style> must have a closing tag", | ||
"start": { | ||
"line": 3, | ||
"column": 22, | ||
"character": 31 | ||
}, | ||
"pos": 31 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<style> | ||
<h1>Hello {name}!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"code": "unclosed-style", | ||
"message": "<style> must have a closing tag", | ||
"start": { | ||
"line": 3, | ||
"column": 7, | ||
"character": 31 | ||
}, | ||
"pos": 31 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>Hello {name}!</h1> | ||
|
||
<style> |
10 changes: 10 additions & 0 deletions
10
test/parser/samples/whitespace-after-script-tag/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<script> | ||
let name = 'world'; | ||
</script | ||
> | ||
<h1>Hello {name}!</h1> |
150 changes: 150 additions & 0 deletions
150
test/parser/samples/whitespace-after-script-tag/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"html": { | ||
"start": 51, | ||
"end": 73, | ||
"type": "Fragment", | ||
"children": [ | ||
{ | ||
"start": 49, | ||
"end": 51, | ||
"type": "Text", | ||
"raw": "\n\n", | ||
"data": "\n\n" | ||
}, | ||
{ | ||
"start": 51, | ||
"end": 73, | ||
"type": "Element", | ||
"name": "h1", | ||
"attributes": [], | ||
"children": [ | ||
{ | ||
"start": 55, | ||
"end": 61, | ||
"type": "Text", | ||
"raw": "Hello ", | ||
"data": "Hello " | ||
}, | ||
{ | ||
"start": 61, | ||
"end": 67, | ||
"type": "MustacheTag", | ||
"expression": { | ||
"type": "Identifier", | ||
"start": 62, | ||
"end": 66, | ||
"loc": { | ||
"start": { | ||
"line": 10, | ||
"column": 11 | ||
}, | ||
"end": { | ||
"line": 10, | ||
"column": 15 | ||
} | ||
}, | ||
"name": "name" | ||
} | ||
}, | ||
{ | ||
"start": 67, | ||
"end": 68, | ||
"type": "Text", | ||
"raw": "!", | ||
"data": "!" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"instance": { | ||
"type": "Script", | ||
"start": 0, | ||
"end": 49, | ||
"context": "default", | ||
"content": { | ||
"type": "Program", | ||
"start": 8, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 0 | ||
} | ||
}, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start": 10, | ||
"end": 29, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 20 | ||
} | ||
}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start": 14, | ||
"end": 28, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 5 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 19 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 14, | ||
"end": 18, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 5 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 9 | ||
} | ||
}, | ||
"name": "name" | ||
}, | ||
"init": { | ||
"type": "Literal", | ||
"start": 21, | ||
"end": 28, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 19 | ||
} | ||
}, | ||
"value": "world", | ||
"raw": "'world'" | ||
} | ||
} | ||
], | ||
"kind": "let" | ||
} | ||
], | ||
"sourceType": "module" | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
test/parser/samples/whitespace-after-style-tag/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div>foo</div> | ||
|
||
<style> | ||
div { | ||
color: red; | ||
} | ||
</style | ||
> |
Oops, something went wrong.