inikulin/parse5

How to use createElement

Closed this issue · 3 comments

How to use createElement seems to exist? I didn't quite understand the use of TreeAdapter.

wooorm commented

This is way too vague. This is an open source project, not customer service. Please expand your question to show what you tried, what you did, what versions you’re using, what you searched for online, etc etc etc.

There are no examples in the documentation, so I had to write it here.

const dom = parse5.parse(page);
let script = dom.createElement('script');
script.innerHTML = fs.readFileSync(`${global.config.directory}/template/test.js`, 'utf8');
dom.head.appendChild(script);
dom.body.setAttribute("onload", `new Example('${random}')`);
return res.html(dom.serialize(), 401);

I am trying to make code like this @wooorm

wooorm commented

Not a lot of docs is a reason to ask a question. Not a reason to not spend the time to make your question clear.

This project doesn’t do what you are looking for. Your pseudocode shows something similar to jsdom