fix: use template element for string to html
This commit is contained in:
parent
f0839e02eb
commit
2d2b238da9
1 changed files with 3 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
const parser = typeof DOMParser !== 'undefined' ? new DOMParser() : null;
|
||||
export let html = (string) => {
|
||||
return parser?.parseFromString(string, 'text/html').querySelectorAll('*');
|
||||
const template = document.createElement('template');
|
||||
template.innerHTML = string.trim();
|
||||
return template.content.childNodes;
|
||||
};
|
||||
let parseChunk = (chunk) => {
|
||||
if (Array.isArray(chunk)) return chunk.flat().join('');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue