tinymce.html.Node

Namespace tinymce.html
Class Node
This class is a minimalistic implementation of a DOM like node used by the DomParser class.
Version:3.4

Example

Public Methods

Method Defined 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
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
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
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

Nodeconstructor

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

Parameters

name:String Name of the node type.
type:Number Numeric type representing the node.

appendmethod

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

Parameters

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

Returns

Node - The node that got appended.

Example

attrmethod

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

Parameters

name:String Attribute name to set or get.
value:String Optional value to set.

Returns

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

Example

clonemethod

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

createmethod

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

Parameters

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

emptymethod

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

Returns

Node - The current node that got cleared.

getAllmethod

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

Parameters

name:String Name of the child nodes to collect.

Returns

Array - Array with child nodes matchin the specified name.

insertmethod

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

node:Node Node to insert as a child of the current node.
ref_node:Node Reference node to set node before/after.
before:Boolean Optional state to insert the node before the reference node.

Returns

Node - The node that got inserted.

Example

isEmptymethod

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

Parameters

elements:Object Name/value object with elements that are automatically treated as non empty elements.

Returns

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

Example

removemethod

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

Returns

Node - Current node that got removed.

Example

replacemethod

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

Parameters

node:Node Node to replace the current node with.

Returns

Node - The old node that got replaced.

Example

unwrapmethod

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

Example

walkmethod

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

prev:Boolean Optional previous node state defaults to false.

Returns

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

wrapmethod

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

Example