mirror of
https://github.com/swc-project/swc.git
synced 2025-01-03 11:01:52 +03:00
fix(html/parser): Fix parsing of comments in textarea
(#4530)
This commit is contained in:
parent
f87d94a50e
commit
79090e1b2a
@ -3,5 +3,5 @@
|
||||
</head>
|
||||
<body>
|
||||
<textarea name=test id=test></textarea>
|
||||
</body>
|
||||
</html></body></html>
|
||||
|
||||
</body></html>
|
||||
|
@ -3398,14 +3398,16 @@ where
|
||||
Token::StartTag { tag_name, .. } if tag_name == "textarea" => {
|
||||
self.insert_html_element(token_and_info)?;
|
||||
|
||||
// To prevent parsing more tokens in lexer we set state before taking
|
||||
self.input.set_input_state(State::Rcdata);
|
||||
|
||||
match self.input.cur()? {
|
||||
Some(Token::Character { value, .. }) if *value == '\x0A' => {
|
||||
bump!(self);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
};
|
||||
|
||||
self.input.set_input_state(State::Rcdata);
|
||||
self.original_insertion_mode = self.insertion_mode.clone();
|
||||
self.frameset_ok = false;
|
||||
self.insertion_mode = InsertionMode::Text;
|
||||
|
@ -0,0 +1 @@
|
||||
<textarea><!--</textarea>--></textarea>
|
@ -0,0 +1,84 @@
|
||||
{
|
||||
"type": "Document",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 39,
|
||||
"ctxt": 0
|
||||
},
|
||||
"mode": "no-quirks",
|
||||
"children": [
|
||||
{
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "html",
|
||||
"namespace": "http://www.w3.org/1999/xhtml",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "head",
|
||||
"namespace": "http://www.w3.org/1999/xhtml",
|
||||
"attributes": [],
|
||||
"children": [],
|
||||
"content": null
|
||||
},
|
||||
{
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "body",
|
||||
"namespace": "http://www.w3.org/1999/xhtml",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 14,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "textarea",
|
||||
"namespace": "http://www.w3.org/1999/xhtml",
|
||||
"attributes": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"span": {
|
||||
"start": 10,
|
||||
"end": 14,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": "<!--"
|
||||
}
|
||||
],
|
||||
"content": null
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"span": {
|
||||
"start": 25,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": "-->"
|
||||
}
|
||||
],
|
||||
"content": null
|
||||
}
|
||||
],
|
||||
"content": null
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
|
||||
x Unexpected token
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^
|
||||
`----
|
@ -0,0 +1,66 @@
|
||||
|
||||
x Document
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Element
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Element
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Element
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Text
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Text
|
||||
,-[$DIR/tests/recovery/comment/inside-textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^
|
||||
`----
|
@ -11,7 +11,7 @@
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "html",
|
||||
@ -35,7 +35,7 @@
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "body",
|
||||
@ -46,14 +46,33 @@
|
||||
"type": "Element",
|
||||
"span": {
|
||||
"start": 0,
|
||||
"end": 10,
|
||||
"end": 14,
|
||||
"ctxt": 0
|
||||
},
|
||||
"tagName": "textarea",
|
||||
"namespace": "http://www.w3.org/1999/xhtml",
|
||||
"attributes": [],
|
||||
"children": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"span": {
|
||||
"start": 10,
|
||||
"end": 14,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": "<!--"
|
||||
}
|
||||
],
|
||||
"content": null
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"span": {
|
||||
"start": 25,
|
||||
"end": 28,
|
||||
"ctxt": 0
|
||||
},
|
||||
"value": "-->"
|
||||
}
|
||||
],
|
||||
"content": null
|
||||
|
@ -5,6 +5,18 @@
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Element
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
@ -16,3 +28,39 @@
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Element
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^^^^^^^^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Text
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^^
|
||||
`----
|
||||
|
||||
x Child
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^
|
||||
`----
|
||||
|
||||
x Text
|
||||
,-[$DIR/tests/recovery/element/textarea/input.html:1:1]
|
||||
1 | <textarea><!--</textarea>--></textarea>
|
||||
: ^^^
|
||||
`----
|
||||
|
Loading…
Reference in New Issue
Block a user