XML DOM - DocumentFragment object
A DocumentFragment object represents adjacent nodes and their subtrees.
DocumentFragment object
The DocumentFragment interface represents a part (or a segment) of the document. More precisely, it represents one or more adjacent Document nodeAnd all their descendant nodes.
The DocumentFragment node does not belong to the document tree, and the inherited parentNode property is always null.
However, it has a special behavior that makes it very useful, that is, when a DocumentFragment node is requested to be inserted into the document tree, it is not the DocumentFragment itself that is inserted, but all its descendant nodes. This makes DocumentFragment a useful placeholder to temporarily store nodes that are inserted into the document at one time. It is also conducive to implementing document cut, copy and paste operations, especially with Range interfaceEspecially when used together.
Can create a new empty DocumentFragment node using Document.createDocumentFragment() method.
Can also be used Range.extractContents() method Or Range.cloneContents() method Get a DocumentFragment node containing the existing document fragment.