Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

fix(node-document): create conditional for non html component #614

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions modules/platform-node/node-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ export function parseDocument (documentHtml: string): any {
throw new Error('parseDocument needs to be a string to be parsed correctly');
}

const doc = parse5.parse(documentHtml, { treeAdapter : parse5.treeAdapters.htmlparser2 });
let doc;


/*
// Build entire doc <!doctype><html> etc
if (documentHtml.indexOf('<html>') > -1 && documentHtml.indexOf('</html>') > -1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still a problem with html tags that have attributes like <html ⚡> or <html lang="en">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally right. Should I clean it up to test for just <html, maybe even look for doctype as well? @gdi2290

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use a regexp looking for any case of doctype

const doc = parser.parse(documentHtml);
doc = parse5.parse(documentHtml, { treeAdapter : parse5.treeAdapters.htmlparser2 });
} else {
// ASP.NET case : parse only the fragment - don't build entire <html> doc
doc = parseFragment(documentHtml);
}
// ASP.NET case : parse only the fragment - don't build entire <html> doc
const doc = parser.parseFragment(documentHtml);
*/


let rootNode = undefined;
let bodyNode = undefined;
Expand Down