tinymce.html.Node
This class is a minimalistic implementation of a DOM like node used by the DomParser class.
Summary
Methods
Name | Summary | Defined by |
---|---|---|
Appends a new node as a child of the current node. |
||
Gets/sets or removes an attribute by name. |
||
Get all children of this 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. |
||
Creates a node of a specific type. |
||
Removes all children of the current node. |
||
Get all descendants by name. |
||
Inserts a node at a specific position as a child of this node. |
||
Returns true/false if the node is to be considered empty or not. |
||
Removes the node from it’s parent. |
||
Replaces the current node with the specified one. |
||
Unwraps the node in other words it removes the node but keeps the children. |
||
Walks to the next or previous node and returns that node or null if it wasn’t found. |
||
Wraps the node in in another node. |
Methods
append()
append(node: tinymce.html.Node): tinymce.html.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.
attr()
attr(name: String, value: String): String | tinymce.html.Node
Gets/sets or removes an attribute by name.
Examples
someNode.attr("name", "value"); // Sets an attribute
console.log(someNode.attr("name")); // Gets an attribute
someNode.attr("name", null); // Removes an attribute
Return value
-
String
- String or undefined on a get operation or the current node on a set operation. -
Node
- String or undefined on a get operation or the current node on a set operation.
clone()
clone(): tinymce.html.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.
insert()
insert(node: tinymce.html.Node, refNode: tinymce.html.Node, before: Boolean): tinymce.html.Node
Inserts a node at a specific position as a child of this node.
isEmpty()
isEmpty(elements: Object, whitespace: Object, predicate: function): 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. -
whitespace (Object)
- Name/value object with elements that are automatically treated whitespace preservables. -
predicate (function)
- Optional predicate that gets called after the other rules determine that the node is empty. Should return true if the node is a content node.
replace()
replace(node: tinymce.html.Node): tinymce.html.Node
Replaces the current node with the specified one.
Parameters
-
node (Node)
- Node to replace the current node with.