0 results found

tinymce.html.Node

Contribute to this page
Namespacetinymce.html
ClassNode

This class is a minimalistic implementation of a DOM like node used by the DomParser class.Version:3.4

Example

Public Methods

MethodDefined By
Node(name:String, type:Number) : Constructs a new Node instance.Node
append(node:Node):Node : Appends a new node as a child of the current node.Node
attr(name:String, value:String):String/Node : Gets/sets or removes an attribute by name.Node
clone():Node : Does a shallow clones the node into a new node.Node
create(name:String, attrs:Object):void : [static] Creates a node of a specific type.Node
empty():Node : Removes all children of the current node.Node
getAll(name:String):Array : Get all children by name.Node
insert(node:Node, ref_node:Node, before:Boolean):Node : Inserts a node at a specific position as a child of the current node.Node
isEmpty(elements:Object):Boolean : Returns true/false if the node is to be considered empty or not.Node
remove():Node : Removes the node from it's parent.Node
replace(node:Node):Node : Replaces the current node with the specified one.Node
unwrap():void : Unwraps the node in other words it removes the node but keeps the children.Node
walk(prev:Boolean):Node : Walks to the next or previous node and returns that node or null if it wasn't found.Node
wrap():void : Wraps the node in in another node.Node

Method details

Node

public function Node(name:String, type:Number)
Constructs a new Node instance.

Parameters

ParamDetail
name:StringName of the node type.
type:NumberNumeric type representing the node.

append

public function append(node:Node):Node
Appends a new node as a child of the current node.

Parameters

ParamDetail
node:NodeNode to append as a child of the current one.

Returns
Node - The node that got appended.

Example

attr

public function attr(name:String, value:String):String/Node
Gets/sets or removes an attribute by name.

Parameters

ParamDetail
name:StringAttribute name to set or get.
value:StringOptional value to set.

Returns
String/Node - String or undefined on a get operation or the current node on a set operation.

Example

clone

public function clone():Node
Does a shallow clones the node into a new node. It will also exclude id attributes since there should only be one id per document.

Returns
Node - New copy of the original node.

Example

create

public static function create(name:String, attrs:Object):void
Creates a node of a specific type.

Parameters

ParamDetail
name:StringName of the node type to create for example "b" or "#text".
attrs:ObjectName/value collection of attributes that will be applied to elements.

empty

public function empty():Node
Removes all children of the current node.

Returns
Node - The current node that got cleared.

getAll

public function getAll(name:String):Array
Get all children by name.

Parameters

ParamDetail
name:StringName of the child nodes to collect.

Returns
Array - Array with child nodes matchin the specified name.

insert

public function insert(node:Node, ref_node:Node, before:Boolean):Node
Inserts a node at a specific position as a child of the current node.

Parameters

ParamDetail
node:NodeNode to insert as a child of the current node.
ref_node:NodeReference node to set node before/after.
before:BooleanOptional state to insert the node before the reference node.

Returns
Node - The node that got inserted.

Example

isEmpty

public function isEmpty(elements:Object):Boolean
Returns true/false if the node is to be considered empty or not.

Parameters

ParamDetail
elements:ObjectName/value object with elements that are automatically treated as non empty elements.

Returns
Boolean - true/false if the node is empty or not.

Example

remove

public function remove():Node
Removes the node from it's parent.

Returns
Node - Current node that got removed.

Example

replace

public function replace(node:Node):Node
Replaces the current node with the specified one.

Parameters

ParamDetail
node:NodeNode to replace the current node with.

Returns
Node - The old node that got replaced.

Example

unwrap

public function unwrap():void
Unwraps the node in other words it removes the node but keeps the children.

Example

walk

public function walk(prev:Boolean):Node
Walks to the next or previous node and returns that node or null if it wasn't found.

Parameters

ParamDetail
prev:BooleanOptional previous node state defaults to false.

Returns
Node - Node that is next to or previous of the current node.

wrap

public function wrap():void
Wraps the node in in another node.

Example

Except as otherwise noted, the content of this page is licensed under the Creative Commons BY-NC-SA 3.0 License, and code samples are licensed under the Apache 2.0 License.