14 lines
491 B
TypeScript
14 lines
491 B
TypeScript
/*
|
|
* https://github.com/morethanwords/tweb
|
|
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
|
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
*/
|
|
|
|
export default function htmlToDocumentFragment(html: string | DocumentFragment) {
|
|
if(html instanceof DocumentFragment) return html;
|
|
const template = document.createElement('template');
|
|
html = html.trim(); // Never return a text node of whitespace as the result
|
|
template.innerHTML = html;
|
|
return template.content;
|
|
}
|