* Returns a DocumentFragment containing the provided HTML string as DOM nodes.
*/
createFragmentFromHtml(html: string): DocumentFragment {
- const tmp = document.createElement("div");
- DomUtil.setInnerHtml(tmp, html);
+ const template = document.createElement("template");
+ DomUtil.setInnerHtml(template, html);
const fragment = document.createDocumentFragment();
- while (tmp.childNodes.length) {
- fragment.appendChild(tmp.childNodes[0]);
- }
+ fragment.append(template.content.cloneNode(true));
return fragment;
},
* Returns a DocumentFragment containing the provided HTML string as DOM nodes.
*/
createFragmentFromHtml(html) {
- const tmp = document.createElement("div");
- DomUtil.setInnerHtml(tmp, html);
+ const template = document.createElement("template");
+ DomUtil.setInnerHtml(template, html);
const fragment = document.createDocumentFragment();
- while (tmp.childNodes.length) {
- fragment.appendChild(tmp.childNodes[0]);
- }
+ fragment.append(template.content.cloneNode(true));
return fragment;
},
/**