Skip to content

Commit

Permalink
close #42 fallback to html when doctype is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuyz0112 committed Sep 6, 2020
1 parent 9d58205 commit 8565b0d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function buildNode(
return doc.implementation.createDocument(null, '', null);
case NodeType.DocumentType:
return doc.implementation.createDocumentType(
n.name,
n.name || 'html',
n.publicId,
n.systemId,
);
Expand Down
9 changes: 9 additions & 0 deletions test/__snapshots__/integration.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@ exports[`[html file]: invalid-attribute.html 1`] = `
</body></html>"
`;
exports[`[html file]: invalid-doctype.html 1`] = `
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
<meta charset=\\"UTF-8\\" />
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
<title>Invalid Doctype</title>
</head>
<body></body></html>"
`;

exports[`[html file]: invalid-tagname.html 1`] = `
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
<meta charset=\\"UTF-8\\" />
Expand Down
9 changes: 9 additions & 0 deletions test/html/invalid-doctype.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE >
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Invalid Doctype</title>
</head>
<body></body>
</html>

0 comments on commit 8565b0d

Please sign in to comment.