From e6042a5e692c785bb12058f1eb63e728f3191cef Mon Sep 17 00:00:00 2001 From: Alexander Akait <4567934+alexander-akait@users.noreply.github.com> Date: Fri, 6 May 2022 07:34:06 +0300 Subject: [PATCH] fix(html/parser): Fix parsing of `nobr` (#4535) --- crates/swc_html_parser/src/parser/mod.rs | 16 +- .../html5lib-tests-fixture/tests26_dat/0.json | 145 ++++++++++++++++-- .../html5lib-tests-fixture/tests26_dat/1.json | 77 +++++++++- .../html5lib-tests-fixture/tests26_dat/2.json | 20 ++- .../html5lib-tests-fixture/tests26_dat/3.json | 20 ++- .../html5lib-tests-fixture/tests26_dat/4.json | 75 ++++++++- .../html5lib-tests-fixture/tests26_dat/5.json | 77 +++++++++- .../html5lib-tests-fixture/tests26_dat/6.json | 45 +++++- .../html5lib-tests-fixture/tests26_dat/7.json | 39 ++++- .../html5lib-tests-fixture/tests26_dat/8.json | 20 ++- .../html5lib-tests-fixture/tests3_dat/20.json | 13 ++ .../html5lib-tests-fixture/tests3_dat/21.json | 13 ++ .../webkit01_dat/31.json | 21 ++- .../tests/recovery/element/nobr-1/input.html | 1 + .../tests/recovery/element/nobr-1/output.json | 102 ++++++++++++ .../recovery/element/nobr-1/output.stderr | 18 +++ .../recovery/element/nobr-1/span.rust-debug | 78 ++++++++++ 17 files changed, 724 insertions(+), 56 deletions(-) create mode 100644 crates/swc_html_parser/tests/recovery/element/nobr-1/input.html create mode 100644 crates/swc_html_parser/tests/recovery/element/nobr-1/output.json create mode 100644 crates/swc_html_parser/tests/recovery/element/nobr-1/output.stderr create mode 100644 crates/swc_html_parser/tests/recovery/element/nobr-1/span.rust-debug diff --git a/crates/swc_html_parser/src/parser/mod.rs b/crates/swc_html_parser/src/parser/mod.rs index ccae540dc72..6566bfad54f 100644 --- a/crates/swc_html_parser/src/parser/mod.rs +++ b/crates/swc_html_parser/src/parser/mod.rs @@ -3075,15 +3075,15 @@ where self.run_the_adoption_agency_algorithm(token_and_info)?; self.reconstruct_active_formatting_elements()?; - } else { - let element = self.insert_html_element(&mut token_and_info.clone())?; - - self.active_formatting_elements - .push(ActiveFormattingElement::Element( - element, - token_and_info.clone(), - )); } + + let element = self.insert_html_element(&mut token_and_info.clone())?; + + self.active_formatting_elements + .push(ActiveFormattingElement::Element( + element, + token_and_info.clone(), + )); } // An end tag whose tag name is one of: "a", "b", "big", "code", "em", "font", // "i", "nobr", "s", "small", "strike", "strong", "tt", "u" diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/0.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/0.json index 6bd70b5a913..b748634463d 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/0.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/0.json @@ -22,7 +22,7 @@ "type": "Element", "span": { "start": 0, - "end": 109, + "end": 115, "ctxt": 0 }, "tagName": "html", @@ -46,7 +46,7 @@ "type": "Element", "span": { "start": 15, - "end": 109, + "end": 115, "ctxt": 0 }, "tagName": "body", @@ -57,7 +57,7 @@ "type": "Element", "span": { "start": 21, - "end": 41, + "end": 47, "ctxt": 0 }, "tagName": "a", @@ -99,6 +99,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 41, + "end": 47, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -106,21 +119,61 @@ { "type": "Element", "span": { - "start": 51, - "end": 55, + "start": 41, + "end": 68, "ctxt": 0 }, - "tagName": "br", + "tagName": "nobr", "namespace": "http://www.w3.org/1999/xhtml", "attributes": [], - "children": [], + "children": [ + { + "type": "Element", + "span": { + "start": 51, + "end": 55, + "ctxt": 0 + }, + "tagName": "br", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, + { + "type": "Element", + "span": { + "start": 55, + "end": 68, + "ctxt": 0 + }, + "tagName": "a", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "href", + "value": "#2" + } + ], + "children": [], + "content": null + } + ], "content": null }, { "type": "Element", "span": { "start": 55, - "end": 75, + "end": 81, "ctxt": 0 }, "tagName": "a", @@ -162,6 +215,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 75, + "end": 81, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -169,21 +235,61 @@ { "type": "Element", "span": { - "start": 85, - "end": 89, + "start": 75, + "end": 102, "ctxt": 0 }, - "tagName": "br", + "tagName": "nobr", "namespace": "http://www.w3.org/1999/xhtml", "attributes": [], - "children": [], + "children": [ + { + "type": "Element", + "span": { + "start": 85, + "end": 89, + "ctxt": 0 + }, + "tagName": "br", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, + { + "type": "Element", + "span": { + "start": 89, + "end": 102, + "ctxt": 0 + }, + "tagName": "a", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [ + { + "type": "Attribute", + "span": { + "start": 0, + "end": 0, + "ctxt": 0 + }, + "namespace": null, + "prefix": null, + "name": "href", + "value": "#3" + } + ], + "children": [], + "content": null + } + ], "content": null }, { "type": "Element", "span": { "start": 89, - "end": 109, + "end": 115, "ctxt": 0 }, "tagName": "a", @@ -225,6 +331,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 109, + "end": 115, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/1.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/1.json index 1bedee23905..be303e5fc46 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/1.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/1.json @@ -57,7 +57,7 @@ "type": "Element", "span": { "start": 21, - "end": 31, + "end": 37, "ctxt": 0 }, "tagName": "b", @@ -86,6 +86,46 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 31, + "end": 37, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + } + ], + "content": null + }, + { + "type": "Element", + "span": { + "start": 31, + "end": 44, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 41, + "end": 44, + "ctxt": 0 + }, + "tagName": "i", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -94,7 +134,7 @@ "type": "Element", "span": { "start": 41, - "end": 51, + "end": 57, "ctxt": 0 }, "tagName": "i", @@ -123,18 +163,45 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 51, + "end": 57, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null }, { - "type": "Text", + "type": "Element", "span": { - "start": 61, + "start": 51, "end": 62, "ctxt": 0 }, - "value": "3" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 61, + "end": 62, + "ctxt": 0 + }, + "value": "3" + } + ], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/2.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/2.json index 18599322693..006b226b573 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/2.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/2.json @@ -123,13 +123,27 @@ "attributes": [], "children": [ { - "type": "Text", + "type": "Element", "span": { - "start": 57, + "start": 51, "end": 58, "ctxt": 0 }, - "value": "2" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 57, + "end": 58, + "ctxt": 0 + }, + "value": "2" + } + ], + "content": null }, { "type": "Element", diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/3.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/3.json index b02a20e0dda..b821ff947d5 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/3.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/3.json @@ -167,13 +167,27 @@ "attributes": [], "children": [ { - "type": "Text", + "type": "Element", "span": { - "start": 65, + "start": 59, "end": 66, "ctxt": 0 }, - "value": "2" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 65, + "end": 66, + "ctxt": 0 + }, + "value": "2" + } + ], + "content": null }, { "type": "Element", diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/4.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/4.json index a660fe6d3ec..810c75106df 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/4.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/4.json @@ -124,6 +124,46 @@ "attributes": [], "children": [], "content": null + }, + { + "type": "Element", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + } + ], + "content": null + }, + { + "type": "Element", + "span": { + "start": 36, + "end": 49, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 46, + "end": 49, + "ctxt": 0 + }, + "tagName": "i", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -132,7 +172,7 @@ "type": "Element", "span": { "start": 46, - "end": 56, + "end": 62, "ctxt": 0 }, "tagName": "i", @@ -161,18 +201,45 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 56, + "end": 62, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null }, { - "type": "Text", + "type": "Element", "span": { - "start": 66, + "start": 56, "end": 67, "ctxt": 0 }, - "value": "3" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 66, + "end": 67, + "ctxt": 0 + }, + "value": "3" + } + ], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/5.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/5.json index 7d982984b77..23ff75bde70 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/5.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/5.json @@ -57,7 +57,7 @@ "type": "Element", "span": { "start": 21, - "end": 31, + "end": 37, "ctxt": 0 }, "tagName": "b", @@ -86,6 +86,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 31, + "end": 37, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -101,11 +114,38 @@ "namespace": "http://www.w3.org/1999/xhtml", "attributes": [], "children": [ + { + "type": "Element", + "span": { + "start": 31, + "end": 49, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 46, + "end": 49, + "ctxt": 0 + }, + "tagName": "i", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + } + ], + "content": null + }, { "type": "Element", "span": { "start": 46, - "end": 56, + "end": 62, "ctxt": 0 }, "tagName": "i", @@ -134,18 +174,45 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 56, + "end": 62, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null }, { - "type": "Text", + "type": "Element", "span": { - "start": 66, + "start": 56, "end": 67, "ctxt": 0 }, - "value": "3" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 66, + "end": 67, + "ctxt": 0 + }, + "value": "3" + } + ], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/6.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/6.json index 32747e313b7..1df1070bfac 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/6.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/6.json @@ -90,11 +90,52 @@ { "type": "Element", "span": { - "start": 37, + "start": 31, "end": 42, "ctxt": 0 }, - "tagName": "ins", + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 37, + "end": 42, + "ctxt": 0 + }, + "tagName": "ins", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + } + ], + "content": null + } + ], + "content": null + }, + { + "type": "Element", + "span": { + "start": 31, + "end": 49, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 46, + "end": 49, + "ctxt": 0 + }, + "tagName": "i", "namespace": "http://www.w3.org/1999/xhtml", "attributes": [], "children": [], diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/7.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/7.json index 408c42fdf80..dc43329937d 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/7.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/7.json @@ -57,7 +57,7 @@ "type": "Element", "span": { "start": 21, - "end": 36, + "end": 42, "ctxt": 0 }, "tagName": "b", @@ -99,6 +99,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 36, + "end": 42, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null @@ -106,22 +119,36 @@ { "type": "Element", "span": { - "start": 46, + "start": 36, "end": 50, "ctxt": 0 }, - "tagName": "i", + "tagName": "nobr", "namespace": "http://www.w3.org/1999/xhtml", "attributes": [], "children": [ { - "type": "Text", + "type": "Element", "span": { - "start": 49, + "start": 46, "end": 50, "ctxt": 0 }, - "value": "2" + "tagName": "i", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 49, + "end": 50, + "ctxt": 0 + }, + "value": "2" + } + ], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/8.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/8.json index 1d0e97b104a..68917453377 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/8.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests26_dat/8.json @@ -128,13 +128,27 @@ "attributes": [], "children": [ { - "type": "Text", + "type": "Element", "span": { - "start": 44, + "start": 38, "end": 45, "ctxt": 0 }, - "value": "2" + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Text", + "span": { + "start": 44, + "end": 45, + "ctxt": 0 + }, + "value": "2" + } + ], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/20.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/20.json index 1887c184c9a..94f2e760793 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/20.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/20.json @@ -66,6 +66,19 @@ "children": [], "content": null }, + { + "type": "Element", + "span": { + "start": 21, + "end": 27, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, { "type": "Element", "span": { diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/21.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/21.json index 813c5e1b393..e117d19a880 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/21.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/tests3_dat/21.json @@ -66,6 +66,19 @@ "children": [], "content": null }, + { + "type": "Element", + "span": { + "start": 21, + "end": 27, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, { "type": "Element", "span": { diff --git a/crates/swc_html_parser/tests/html5lib-tests-fixture/webkit01_dat/31.json b/crates/swc_html_parser/tests/html5lib-tests-fixture/webkit01_dat/31.json index f4967f9ee47..fd2e5673da5 100644 --- a/crates/swc_html_parser/tests/html5lib-tests-fixture/webkit01_dat/31.json +++ b/crates/swc_html_parser/tests/html5lib-tests-fixture/webkit01_dat/31.json @@ -11,7 +11,7 @@ "type": "Element", "span": { "start": 0, - "end": 26, + "end": 32, "ctxt": 0 }, "tagName": "html", @@ -35,7 +35,7 @@ "type": "Element", "span": { "start": 0, - "end": 26, + "end": 32, "ctxt": 0 }, "tagName": "body", @@ -73,7 +73,7 @@ "type": "Element", "span": { "start": 14, - "end": 26, + "end": 32, "ctxt": 0 }, "tagName": "div", @@ -84,7 +84,7 @@ "type": "Element", "span": { "start": 5, - "end": 26, + "end": 32, "ctxt": 0 }, "tagName": "b", @@ -113,6 +113,19 @@ } ], "content": null + }, + { + "type": "Element", + "span": { + "start": 26, + "end": 32, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null } ], "content": null diff --git a/crates/swc_html_parser/tests/recovery/element/nobr-1/input.html b/crates/swc_html_parser/tests/recovery/element/nobr-1/input.html new file mode 100644 index 00000000000..af365a4413d --- /dev/null +++ b/crates/swc_html_parser/tests/recovery/element/nobr-1/input.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/crates/swc_html_parser/tests/recovery/element/nobr-1/output.json b/crates/swc_html_parser/tests/recovery/element/nobr-1/output.json new file mode 100644 index 00000000000..94f2e760793 --- /dev/null +++ b/crates/swc_html_parser/tests/recovery/element/nobr-1/output.json @@ -0,0 +1,102 @@ +{ + "type": "Document", + "span": { + "start": 0, + "end": 33, + "ctxt": 0 + }, + "mode": "no-quirks", + "children": [ + { + "type": "DocumentType", + "span": { + "start": 0, + "end": 15, + "ctxt": 0 + }, + "name": "html", + "publicId": null, + "systemId": null + }, + { + "type": "Element", + "span": { + "start": 0, + "end": 33, + "ctxt": 0 + }, + "tagName": "html", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 0, + "end": 21, + "ctxt": 0 + }, + "tagName": "head", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, + { + "type": "Element", + "span": { + "start": 0, + "end": 33, + "ctxt": 0 + }, + "tagName": "body", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [ + { + "type": "Element", + "span": { + "start": 15, + "end": 21, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, + { + "type": "Element", + "span": { + "start": 21, + "end": 27, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + }, + { + "type": "Element", + "span": { + "start": 27, + "end": 33, + "ctxt": 0 + }, + "tagName": "nobr", + "namespace": "http://www.w3.org/1999/xhtml", + "attributes": [], + "children": [], + "content": null + } + ], + "content": null + } + ], + "content": null + } + ] +} diff --git a/crates/swc_html_parser/tests/recovery/element/nobr-1/output.stderr b/crates/swc_html_parser/tests/recovery/element/nobr-1/output.stderr new file mode 100644 index 00000000000..69ece9b41d7 --- /dev/null +++ b/crates/swc_html_parser/tests/recovery/element/nobr-1/output.stderr @@ -0,0 +1,18 @@ + + x Unexpected token + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Unexpected token + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Unexpected token + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- diff --git a/crates/swc_html_parser/tests/recovery/element/nobr-1/span.rust-debug b/crates/swc_html_parser/tests/recovery/element/nobr-1/span.rust-debug new file mode 100644 index 00000000000..8f6dfa69434 --- /dev/null +++ b/crates/swc_html_parser/tests/recovery/element/nobr-1/span.rust-debug @@ -0,0 +1,78 @@ + + x Document + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^ + `---- + + x DocumentType + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^^^^^^^^^^^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Child + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `---- + + x Element + ,-[$DIR/tests/recovery/element/nobr-1/input.html:1:1] + 1 | + : ^^^^^^ + `----