--- title: document.createDocumentFragment slug: Web/API/Document/createDocumentFragment tags: - DOM - Dokumentacja_Gecko_DOM - Gecko - Wszystkie_kategorie translation_of: Web/API/Document/createDocumentFragment ---
{{ ApiRef() }}
Tworzy pusty fragment dokumentu.
var fragmentDokumentu = document.createDocumentFragment();
fragmentDokumentu jest odniesieniem do pustego obiektu DocumentFragment.
var frag = document.createDocumentFragment();
frag.appendChild(document.createTextNode('Ipsum Lorem'));
document.body.appendChild(frag);
DocumentFragment jest minimalnym obiektem dokumentu, który nie posiada rodzica. Obsługuje on następujące metody DOM 2: appendChild, cloneNode, hasAttributes, hasChildNodes, insertBefore, normalize, removeChild, replaceChild.
Obsługuje on również następujące własności DOM 2: attributes, childNodes, firstChild, lastChild, localName, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, prefix, previousSibling, textContent.
Różne inne metody potrafią pobrać fragment dokumentu jako argument (na przykład metody interfejsu Node takie jak appendChild i insertBefore), w przypadku których dodawane lub wstawiane są dzieci fragmentu, nie zaś same fragmenty.
{{ languages( { "en": "en/DOM/document.createDocumentFragment" } ) }}