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 ] ) → documentFragment
CKEDITOR.dom.documentFragment#constructor
Creates a document fragment class instance.
Parameters
[ nodeOrDoc ] : document | DocumentFragment
-
Defaults to
CKEDITOR.document
Returns
documentFragment
-
append( node, [ toStart ] ) → node
CKEDITOR.dom.documentFragment#append
Append 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 | String
The node or element name to be appended.
[ toStart ] : Boolean
Indicates that the element is to be appended at the start.
Defaults to
false
Returns
node
The appended node.
-
appendBogus( [ force ] )
CKEDITOR.dom.documentFragment#appendBogus
Appends 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 whenforce
is set totrue
filler will be appended regardless of the environment.Parameters
[ force ] : Boolean
Append filler regardless of the environment.
-
appendTo( element ) → element
CKEDITOR.dom.documentFragment#appendTo
Makes 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 : element
The target element to which this node will be appended.
Returns
element
The target element.
-
clone( [ includeChildren ], [ cloneId ] ) → node
CKEDITOR.dom.documentFragment#clone
Clones this node.
Note: Values set by {#setCustomData} will not be available in the clone.
Parameters
[ includeChildren ] : Boolean
If
true
then all node's children will be cloned recursively.Defaults to
false
[ cloneId ] : Boolean
Whether ID attributes should be cloned, too.
Defaults to
false
Returns
node
Clone 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 : String
A valid CSS selector.
Returns
nodeList
-
Wrapper for
querySelector
. Returns the first element within this document that matches the specifiedselector
.Parameters
selector : String
A valid CSS selector.
Returns
element
-
getChild( indices ) → node
CKEDITOR.dom.documentFragment#getChild
Gets a DOM tree descendant under the current node.
var strong = p.getChild( 0 );
Parameters
indices : Array | Number
The child index or array of child indices under the node.
Returns
node
The specified DOM child under the current node. Null if child does not exist.
-
getChildCount() → Number
CKEDITOR.dom.documentFragment#getChildCount
-
getChildren() → nodeList
CKEDITOR.dom.documentFragment#getChildren
-
getDocument() → document
CKEDITOR.dom.documentFragment#getDocument
Gets the document containing this element.
var element = CKEDITOR.document.getById( 'example' ); alert( element.getDocument().equals( CKEDITOR.document ) ); // true
Returns
document
The document.
-
getFirst( evaluator ) → node
CKEDITOR.dom.documentFragment#getFirst
Gets 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 : Function
Filtering the result node.
Returns
node
The first child node or null if not available.
-
Gets the HTML of this document fragment's children.
Returns
String
The HTML of this document fragment's children.
-
getLast( evaluator ) → node
CKEDITOR.dom.documentFragment#getLast
-
getNext( [ evaluator ] ) → node
CKEDITOR.dom.documentFragment#getNext
Gets 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 ] : Function
Filtering the result node.
Returns
node
The next node or null if not available.
-
getParent( [ allowFragmentParent ] ) → element
CKEDITOR.dom.documentFragment#getParent
Gets the parent element for this node.
var node = editor.document.getBody().getFirst(); var parent = node.getParent(); alert( parent.getName() ); // 'body'
Parameters
[ allowFragmentParent ] : Boolean
Consider also parent node that is of fragment type CKEDITOR.NODE_DOCUMENT_FRAGMENT.
Defaults to
false
Returns
element
The parent element.
-
getPrevious( [ evaluator ] ) → node
CKEDITOR.dom.documentFragment#getPrevious
Gets 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 ] : Function
Filtering the result node.
Returns
node
The previous node or null if not available.
-
insertAfterNode( node )
CKEDITOR.dom.documentFragment#insertAfterNode
-
insertBefore( node ) → node
CKEDITOR.dom.documentFragment#insertBefore
Inserts 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 : node
The node that will succeed this element.
Returns
node
The node being inserted.
-
ltrim()
CKEDITOR.dom.documentFragment#ltrim
-
moveChildren( target, [ toStart ] )
CKEDITOR.dom.documentFragment#moveChildren
Moves this element's children to the target element.
Parameters
target : element
[ toStart ] : Boolean
Insert moved children at the beginning of the target element.
Defaults to
false
-
replace()
CKEDITOR.dom.documentFragment#replace
-
rtrim()
CKEDITOR.dom.documentFragment#rtrim
-
trim()
CKEDITOR.dom.documentFragment#trim