How to use createElement
Closed this issue · 3 comments
Fantros commented
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.
Fantros commented
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