Skip to content

Window.createFragment method

Window › createFragment

Official

Creates a new document fragment.

Signature:

createFragment(callback?: ((el: DocumentFragment) => void) | undefined): DocumentFragment

Parameters:

Parameter Type Description
callback? ((el: DocumentFragment) => void) | undefined A callback function to be called when the element is created.

Returns: DocumentFragmentThe created element.

Example:

createFragment((fragment) => {
fragment.createEl('p', { text: 'foo' });
});