+|
+| "cell"
+|
diff --git a/crates/swc_html_parser/tests/fixture/element/template-1/input.html b/crates/swc_html_parser/tests/fixture/element/template-1/input.html
new file mode 100644
index 00000000000..aec9d8ff37c
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-1/input.html
@@ -0,0 +1 @@
+cell |
\ No newline at end of file
diff --git a/crates/swc_html_parser/tests/fixture/element/template-1/output.json b/crates/swc_html_parser/tests/fixture/element/template-1/output.json
new file mode 100644
index 00000000000..58036b09d8c
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-1/output.json
@@ -0,0 +1,130 @@
+{
+ "type": "Document",
+ "span": {
+ "start": 1,
+ "end": 59,
+ "ctxt": 0
+ },
+ "mode": "no-quirks",
+ "children": [
+ {
+ "type": "DocumentType",
+ "span": {
+ "start": 1,
+ "end": 16,
+ "ctxt": 0
+ },
+ "name": "html",
+ "publicId": null,
+ "systemId": null,
+ "raw": ""
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "html",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "head",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 16,
+ "end": 59,
+ "ctxt": 0
+ },
+ "tagName": "template",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": {
+ "type": "DocumentFragment",
+ "span": {
+ "start": 16,
+ "end": 59,
+ "ctxt": 0
+ },
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 26,
+ "end": 48,
+ "ctxt": 0
+ },
+ "tagName": "tr",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 30,
+ "end": 43,
+ "ctxt": 0
+ },
+ "tagName": "td",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Text",
+ "span": {
+ "start": 34,
+ "end": 38,
+ "ctxt": 0
+ },
+ "data": "cell",
+ "raw": "cell"
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ]
+ },
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "body",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ]
+}
diff --git a/crates/swc_html_parser/tests/fixture/element/template-1/span.rust-debug b/crates/swc_html_parser/tests/fixture/element/template-1/span.rust-debug
new file mode 100644
index 00000000000..5c2d8794432
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-1/span.rust-debug
@@ -0,0 +1,76 @@
+
+ x Document
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentType
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+
+ x Element
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentFragment
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-1/input.html:1:1]
+ 1 | cell |
+ : ^^^^
+ `----
diff --git a/crates/swc_html_parser/tests/fixture/element/template-2/dom.rust-debug b/crates/swc_html_parser/tests/fixture/element/template-2/dom.rust-debug
new file mode 100644
index 00000000000..93309e6faa8
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-2/dom.rust-debug
@@ -0,0 +1,13 @@
+|
+|
+|
+|
+| content
+| " "
+|
+| " "
+|
+| "cell"
+| " "
+| " "
+|
diff --git a/crates/swc_html_parser/tests/fixture/element/template-2/input.html b/crates/swc_html_parser/tests/fixture/element/template-2/input.html
new file mode 100644
index 00000000000..40a8ac69680
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-2/input.html
@@ -0,0 +1 @@
+ cell |
\ No newline at end of file
diff --git a/crates/swc_html_parser/tests/fixture/element/template-2/output.json b/crates/swc_html_parser/tests/fixture/element/template-2/output.json
new file mode 100644
index 00000000000..551fe596155
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-2/output.json
@@ -0,0 +1,170 @@
+{
+ "type": "Document",
+ "span": {
+ "start": 1,
+ "end": 63,
+ "ctxt": 0
+ },
+ "mode": "no-quirks",
+ "children": [
+ {
+ "type": "DocumentType",
+ "span": {
+ "start": 1,
+ "end": 16,
+ "ctxt": 0
+ },
+ "name": "html",
+ "publicId": null,
+ "systemId": null,
+ "raw": ""
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "html",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "head",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 16,
+ "end": 63,
+ "ctxt": 0
+ },
+ "tagName": "template",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": {
+ "type": "DocumentFragment",
+ "span": {
+ "start": 16,
+ "end": 63,
+ "ctxt": 0
+ },
+ "children": [
+ {
+ "type": "Text",
+ "span": {
+ "start": 26,
+ "end": 27,
+ "ctxt": 0
+ },
+ "data": " ",
+ "raw": " "
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 27,
+ "end": 51,
+ "ctxt": 0
+ },
+ "tagName": "tr",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Text",
+ "span": {
+ "start": 31,
+ "end": 32,
+ "ctxt": 0
+ },
+ "data": " ",
+ "raw": " "
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 32,
+ "end": 45,
+ "ctxt": 0
+ },
+ "tagName": "td",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Text",
+ "span": {
+ "start": 36,
+ "end": 40,
+ "ctxt": 0
+ },
+ "data": "cell",
+ "raw": "cell"
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Text",
+ "span": {
+ "start": 45,
+ "end": 46,
+ "ctxt": 0
+ },
+ "data": " ",
+ "raw": " "
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Text",
+ "span": {
+ "start": 51,
+ "end": 52,
+ "ctxt": 0
+ },
+ "data": " ",
+ "raw": " "
+ }
+ ]
+ },
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "body",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ]
+}
diff --git a/crates/swc_html_parser/tests/fixture/element/template-2/span.rust-debug b/crates/swc_html_parser/tests/fixture/element/template-2/span.rust-debug
new file mode 100644
index 00000000000..61f4cf842e3
--- /dev/null
+++ b/crates/swc_html_parser/tests/fixture/element/template-2/span.rust-debug
@@ -0,0 +1,124 @@
+
+ x Document
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentType
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+
+ x Element
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentFragment
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Child
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
+
+ x Text
+ ,-[$DIR/tests/fixture/element/template-2/input.html:1:1]
+ 1 | cell |
+ : ^
+ `----
diff --git a/crates/swc_html_parser/tests/recovery/element/template-5/dom.rust-debug b/crates/swc_html_parser/tests/recovery/element/template-5/dom.rust-debug
new file mode 100644
index 00000000000..3431912f887
--- /dev/null
+++ b/crates/swc_html_parser/tests/recovery/element/template-5/dom.rust-debug
@@ -0,0 +1,10 @@
+|
+|
+|
+|
+| content
+|
+|
+| "cell"
+| "a"
+|
diff --git a/crates/swc_html_parser/tests/recovery/element/template-5/input.html b/crates/swc_html_parser/tests/recovery/element/template-5/input.html
new file mode 100644
index 00000000000..a2082234286
--- /dev/null
+++ b/crates/swc_html_parser/tests/recovery/element/template-5/input.html
@@ -0,0 +1 @@
+cell | a
\ No newline at end of file
diff --git a/crates/swc_html_parser/tests/recovery/element/template-5/output.json b/crates/swc_html_parser/tests/recovery/element/template-5/output.json
new file mode 100644
index 00000000000..4291c3e2109
--- /dev/null
+++ b/crates/swc_html_parser/tests/recovery/element/template-5/output.json
@@ -0,0 +1,140 @@
+{
+ "type": "Document",
+ "span": {
+ "start": 1,
+ "end": 60,
+ "ctxt": 0
+ },
+ "mode": "no-quirks",
+ "children": [
+ {
+ "type": "DocumentType",
+ "span": {
+ "start": 1,
+ "end": 16,
+ "ctxt": 0
+ },
+ "name": "html",
+ "publicId": null,
+ "systemId": null,
+ "raw": ""
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "html",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "head",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 16,
+ "end": 60,
+ "ctxt": 0
+ },
+ "tagName": "template",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": {
+ "type": "DocumentFragment",
+ "span": {
+ "start": 16,
+ "end": 60,
+ "ctxt": 0
+ },
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 26,
+ "end": 48,
+ "ctxt": 0
+ },
+ "tagName": "tr",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Element",
+ "span": {
+ "start": 30,
+ "end": 43,
+ "ctxt": 0
+ },
+ "tagName": "td",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [
+ {
+ "type": "Text",
+ "span": {
+ "start": 34,
+ "end": 38,
+ "ctxt": 0
+ },
+ "data": "cell",
+ "raw": "cell"
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Text",
+ "span": {
+ "start": 48,
+ "end": 49,
+ "ctxt": 0
+ },
+ "data": "a",
+ "raw": "a"
+ }
+ ]
+ },
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ },
+ {
+ "type": "Element",
+ "span": {
+ "start": 0,
+ "end": 0,
+ "ctxt": 0
+ },
+ "tagName": "body",
+ "namespace": "http://www.w3.org/1999/xhtml",
+ "attributes": [],
+ "children": [],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ],
+ "content": null,
+ "isSelfClosing": false
+ }
+ ]
+}
diff --git a/crates/swc_html_parser/tests/recovery/element/template-5/output.stderr b/crates/swc_html_parser/tests/recovery/element/template-5/output.stderr
new file mode 100644
index 00000000000..f83f6108a26
--- /dev/null
+++ b/crates/swc_html_parser/tests/recovery/element/template-5/output.stderr
@@ -0,0 +1,6 @@
+
+ x Misplaced non-space characters inside a table
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^
+ `----
diff --git a/crates/swc_html_parser/tests/recovery/element/template-5/span.rust-debug b/crates/swc_html_parser/tests/recovery/element/template-5/span.rust-debug
new file mode 100644
index 00000000000..0c2496973ba
--- /dev/null
+++ b/crates/swc_html_parser/tests/recovery/element/template-5/span.rust-debug
@@ -0,0 +1,88 @@
+
+ x Document
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentType
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+
+ x Element
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x DocumentFragment
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Element
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^^^^^^^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^
+ `----
+
+ x Text
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^^^^
+ `----
+
+ x Child
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^
+ `----
+
+ x Text
+ ,-[$DIR/tests/recovery/element/template-5/input.html:1:1]
+ 1 | cell | a
+ : ^
+ `----
| | |