Skip to content

Commit 8565b0d

Browse files
committed
close #42 fallback to html when doctype is invalid
1 parent 9d58205 commit 8565b0d

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/rebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function buildNode(
8585
return doc.implementation.createDocument(null, '', null);
8686
case NodeType.DocumentType:
8787
return doc.implementation.createDocumentType(
88-
n.name,
88+
n.name || 'html',
8989
n.publicId,
9090
n.systemId,
9191
);

test/__snapshots__/integration.ts.snap

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ exports[`[html file]: invalid-attribute.html 1`] = `
175175
</body></html>"
176176
`;
177177
178+
exports[`[html file]: invalid-doctype.html 1`] = `
179+
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
180+
<meta charset=\\"UTF-8\\" />
181+
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
182+
<title>Invalid Doctype</title>
183+
</head>
184+
<body></body></html>"
185+
`;
186+
178187
exports[`[html file]: invalid-tagname.html 1`] = `
179188
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
180189
<meta charset=\\"UTF-8\\" />

test/html/invalid-doctype.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE >
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Invalid Doctype</title>
7+
</head>
8+
<body></body>
9+
</html>

0 commit comments

Comments
 (0)