This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse-common/addon/lib/dom-from-string.js
Natalie Tay dd3ed27930
DEV: Allow utility class domFromString to take in strings with multiple top level elements (#15548)
Previously only `<div>one top element</div>` was allowed because we use `firstChild` instead of `children`.
We also want `<div>one</div><div>two</div>` to work with this method.
2022-01-12 19:49:24 +08:00

7 lines
198 B
JavaScript

export default function domFromString(string) {
const template = document.createElement("template");
string = string.trim();
template.innerHTML = string;
return template.content.children;
}