generic-node
An implementation of a node in JavaScript.
API
new Node()
The constructor. Takes no parameters.
Example:
var node = ;
#add(Node)
Adds a child node to this node.
If the specified node is already a child of a node it will not be added.
Returns true if the node was added; otherwise false.
Example:
var parentNode = ;var node = ;parentNode; // -> trueparentNode; // -> false!
Event: "added"
Emitted when a node is added to this node. Provides the node that was added as a property in the callback.
Example:
parentNode;
#remove(Node)
Removes a child node from this node. Returns true if the node was removed; otherwise false.
Example:
var parentNode = ;var node = ;parentNode; // -> trueparentNode; // -> false! { parentNode;};
Event: "removed"
Emitted when a node is removed from this node. Provides the node that was removed as a property in the callback.
Example:
parentNode;
#isChild()
Checks if this node is a child of another node.
Returns true if this node is a child of another node; otherwise false.
Example:
var parentNode = ;var node = ;parentNode;node; // -> trueparentNode // -> false, this node has no parent