CKEDITOR.dom.documentFragment
DocumentFragment is a "lightweight" or "minimal" Document object. It is commonly used to extract a portion of the document's tree or to create a new fragment of the document. Various operations may take document fragment objects as arguments and result in all the child nodes of the document fragment being moved to the child list of this node.
Filtering
Properties
-
The node type. This is a constant value set to CKEDITOR.NODE_DOCUMENT_FRAGMENT.
Defaults to
CKEDITOR.NODE_DOCUMENT_FRAGMENT
Methods
constructor( [ nodeOrDoc ] ) → documentFragmentCKEDITOR.dom.documentFragment#constructorCreates a document fragment class instance.
Parameters
[ nodeOrDoc ] : document | DocumentFragmentDefaults to
CKEDITOR.document
Returns
documentFragment
append( node, [ toStart ] ) → nodeCKEDITOR.dom.documentFragment#appendAppend a node as a child of this element.
var p = new CKEDITOR.dom.element( 'p' ); var strong = new CKEDITOR.dom.element( 'strong' ); p.append( strong ); var em = p.append( 'em' ); // Result: '<p><strong></strong><em></em></p>'Parameters
node : node | StringThe node or element name to be appended.
[ toStart ] : BooleanIndicates that the element is to be appended at the start.
Defaults to
false
Returns
nodeThe appended node.
appendBogus( [ force ] )CKEDITOR.dom.documentFragment#appendBogusAppends a
<br>filler element to this element if the filler is not present already. By default filler is appended only if CKEDITOR.env.needsBrFiller istrue, however whenforceis set totruefiller will be appended regardless of the environment.Parameters
[ force ] : BooleanAppend filler regardless of the environment.
appendTo( element ) → elementCKEDITOR.dom.documentFragment#appendToMakes this node a child of another element.
var p = new CKEDITOR.dom.element( 'p' ); var strong = new CKEDITOR.dom.element( 'strong' ); strong.appendTo( p ); // Result: '<p><strong></strong></p>'.Parameters
element : elementThe target element to which this node will be appended.
Returns
elementThe target element.
clone( [ includeChildren ], [ cloneId ] ) → nodeCKEDITOR.dom.documentFragment#cloneClones this node.
Note: Values set by {#setCustomData} will not be available in the clone.
Parameters
[ includeChildren ] : BooleanIf
truethen all node's children will be cloned recursively.Defaults to
false[ cloneId ] : BooleanWhether ID attributes should be cloned, too.
Defaults to
false
Returns
nodeClone of this node.
-
Wrapper for
querySelectorAll. Returns a list of elements within this document that match the specifiedselector.Note: The returned list is not a live collection (like the result of native
querySelectorAll).Parameters
selector : StringA valid CSS selector.
Returns
nodeList
-
Wrapper for
querySelector. Returns the first element within this document that matches the specifiedselector.Parameters
selector : StringA valid CSS selector.
Returns
element
getChild( indices ) → nodeCKEDITOR.dom.documentFragment#getChildGets a DOM tree descendant under the current node.
var strong = p.getChild( 0 );Parameters
indices : Array | NumberThe child index or array of child indices under the node.
Returns
nodeThe specified DOM child under the current node. Null if child does not exist.
getChildCount() → NumberCKEDITOR.dom.documentFragment#getChildCountgetChildren() → nodeListCKEDITOR.dom.documentFragment#getChildrengetDocument() → documentCKEDITOR.dom.documentFragment#getDocumentGets the document containing this element.
var element = CKEDITOR.document.getById( 'example' ); alert( element.getDocument().equals( CKEDITOR.document ) ); // trueReturns
documentThe document.
getFirst( evaluator ) → nodeCKEDITOR.dom.documentFragment#getFirstGets the first child node of this element.
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' ); var first = element.getFirst(); alert( first.getName() ); // 'b'Parameters
evaluator : FunctionFiltering the result node.
Returns
nodeThe first child node or null if not available.
-
Gets the HTML of this document fragment's children.
Returns
StringThe HTML of this document fragment's children.
getLast( evaluator ) → nodeCKEDITOR.dom.documentFragment#getLastgetNext( [ evaluator ] ) → nodeCKEDITOR.dom.documentFragment#getNextGets the node that follows this element in its parent's child list.
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b><i>next</i></div>' ); var last = element.getFirst().getNext(); alert( last.getName() ); // 'i'Parameters
[ evaluator ] : FunctionFiltering the result node.
Returns
nodeThe next node or null if not available.
getParent( [ allowFragmentParent ] ) → elementCKEDITOR.dom.documentFragment#getParentGets the parent element for this node.
var node = editor.document.getBody().getFirst(); var parent = node.getParent(); alert( parent.getName() ); // 'body'Parameters
[ allowFragmentParent ] : BooleanConsider also parent node that is of fragment type CKEDITOR.NODE_DOCUMENT_FRAGMENT.
Defaults to
false
Returns
elementThe parent element.
getPrevious( [ evaluator ] ) → nodeCKEDITOR.dom.documentFragment#getPreviousGets the node that preceeds this element in its parent's child list.
var element = CKEDITOR.dom.element.createFromHtml( '<div><i>prev</i><b>Example</b></div>' ); var first = element.getLast().getPrev(); alert( first.getName() ); // 'i'Parameters
[ evaluator ] : FunctionFiltering the result node.
Returns
nodeThe previous node or null if not available.
insertAfterNode( node )CKEDITOR.dom.documentFragment#insertAfterNodeinsertBefore( node ) → nodeCKEDITOR.dom.documentFragment#insertBeforeInserts this element before a node.
var em = new CKEDITOR.dom.element( 'em' ); var strong = new CKEDITOR.dom.element( 'strong' ); strong.insertBefore( em ); // result: '<strong></strong><em></em>'Parameters
node : nodeThe node that will succeed this element.
Returns
nodeThe node being inserted.
ltrim()CKEDITOR.dom.documentFragment#ltrimmoveChildren( target, [ toStart ] )CKEDITOR.dom.documentFragment#moveChildrenMoves this element's children to the target element.
Parameters
target : element[ toStart ] : BooleanInsert moved children at the beginning of the target element.
Defaults to
false
replace()CKEDITOR.dom.documentFragment#replacertrim()CKEDITOR.dom.documentFragment#rtrimtrim()CKEDITOR.dom.documentFragment#trim