Class

DocumentFragment (engine/view)

@ckeditor/ckeditor5-engine/src/view/documentfragment

class

Document fragment.

To create a new document fragment instance use the UpcastWriter#createDocumentFragment() method.

Filtering

Properties

  • childCount : Number

    readonly

    Number of child nodes in this document fragment.

  • document : Document

    readonly

    The document to which this document fragment belongs.

  • isEmpty : Boolean

    readonly

    Is true if there are no nodes inside this document fragment, false otherwise.

  • parent : null

    readonly

    Artificial parent of DocumentFragment. Returns null. Added for compatibility reasons.

  • root : DocumentFragment

    readonly

    Artificial root of DocumentFragment. Returns itself. Added for compatibility reasons.

  • _children : Array.<Element>

    protected

    Array of child nodes.

Methods

  • constructor( document, [ children ] )

    protected

    Creates new DocumentFragment instance.

    Parameters

    document : Document

    The document to which this document fragment belongs.

    [ children ] : Node | Iterable.<Node>

    A list of nodes to be inserted into the created document fragment.

  • Symbol.iterator() → Iterable.<Node>

    Iterable interface.

    Iterates over nodes added to this document fragment.

    Returns

    Iterable.<Node>
  • _appendChild( items ) → Number

    Insert a child node or a list of child nodes at the end and sets the parent of these nodes to this fragment.

    Parameters

    items : Item | Iterable.<Item>

    Items to be inserted.

    Returns

    Number

    Number of appended nodes.

  • _insertChild( index, items ) → Number

    Inserts a child node or a list of child nodes on the given index and sets the parent of these nodes to this fragment.

    Parameters

    index : Number

    Position where nodes should be inserted.

    items : Item | Iterable.<Item>

    Items to be inserted.

    Returns

    Number

    Number of inserted nodes.

  • _removeChildren( index, [ howMany ] ) → Array.<Node>

    Removes number of child nodes starting at the given index and set the parent of these nodes to null.

    Parameters

    index : Number

    Number of the first node to remove.

    [ howMany ] : Number

    Number of nodes to remove.

    Defaults to 1

    Returns

    Array.<Node>

    The array of removed nodes.

  • getChild( index ) → Node

    Gets child at the given index.

    Parameters

    index : Number

    Index of child.

    Returns

    Node

    Child node.

  • getChildIndex( node ) → Number

    Gets index of the given child node. Returns -1 if child node is not found.

    Parameters

    node : Node

    Child node.

    Returns

    Number

    Index of the child node.

  • getChildren() → Iterable.<Node>

    Gets child nodes iterator.

    Returns

    Iterable.<Node>

    Child nodes iterator.

  • is( type ) → Boolean

    Checks whether this object is of the given type.

    docFrag.is( 'documentFragment' ); // -> true
    docFrag.is( 'view:documentFragment' ); // -> true
    
    docFrag.is( 'model:documentFragment' ); // -> false
    docFrag.is( 'element' ); // -> false
    docFrag.is( 'node' ); // -> false
    

    Check the entire list of view objects which implement the is() method.

    Parameters

    type : String

    Returns

    Boolean
  • _fireChange( type, node )

    private

    Fires change event with given type of the change.

    Parameters

    type : ChangeType

    Type of the change.

    node : Node

    Changed node.

    Fires