Last active
July 7, 2020 15:51
-
-
Save AleksandrChukhray/d8573d3f2b9bad0b75936b3ee6f12839 to your computer and use it in GitHub Desktop.
fragment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function fragment(html) { | |
| var elt = document.createElement("div"); // Пустой элемент | |
| var frag = document.createDocumentFragment(); // Пустой фрагмент | |
| elt.innerHTML = html; // Содержимое элемента | |
| while (elt.firstChild) // Переместить все узлы | |
| frag.appendChild(elt.firstChild); // из elt в frag | |
| return frag; // И вернуть frag | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment