Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setTimeout(async () => {
try {
await this.evaluateInPage(`(${createHelpers})()`);
const snapshot: DocumentData = await this.evaluateInPage('__webhint.snapshotDocument(document)');
restoreReferences(snapshot);
this._document = new HTMLDocument(snapshot, location.href, this._originalDocument);
await this.sendFetchEndEvents();
await traverse(this._document, this._engine, resource);
/*
* Evaluate after the traversing, just in case something goes wrong
* in any of the evaluation and some scripts are left in the DOM.
*/
const event = {
document: this._document,
resource
};
const createHTMLFragment = (roots: RootMap, resource: string) => {
const dom = parse5.parse(
``,
{ treeAdapter: htmlparser2Adapter }
) as DocumentData;
const body = (dom.children[1] as ElementData).children[1] as ElementData;
roots.forEach((root) => {
body.children.push(root);
});
restoreReferences(dom);
return new HTMLDocument(dom, resource);
};