new Node()
A constructor function for creating Node objects with ordered children
to be used as part of the composite design pattern.
Do not mutate the elements of the childNodes array directly.
Instead use the appendChild, insertBefore, replaceChild, and removeChild
methods to manage the children.
var node = new hijos.Node();
- Source:
- maria.js, line 651
Extends
Members
-
<static> superConstructor
-
- Source:
- maria.js, line 663
Properties:
Name Type Description hijos.Node.superConstructor -
<readonly> childNodes :Array
-
The array of child objects.
- Source:
- maria.js, line 674
-
<readonly> firstChild :hijos.Leaf
-
The first child of this object. Null if this object has no children.
- Source:
- maria.js, line 676
-
<readonly> lastChild :hijos.Leaf
-
The last child of this object. Null if this object has no children.
- Source:
- maria.js, line 678
-
<readonly> nextSibling :hijos.Leaf
-
The next sibling
Leafof this object. Null if this object is not the child of anyNodeor this object is the last child of aNode.- Inherited From:
- Source:
- maria.js, line 569
-
<readonly> parentNode :hijos.Leaf
-
The parent
Nodeof this object. Null if this object is not the child of anyNode.- Inherited From:
- Source:
- maria.js, line 565
-
<readonly> previousSibling :hijos.Leaf
-
The previous sibling
Leafof this object. Null if this object is not the child of anyNodeor this object is the first child of aNode.- Inherited From:
- Source:
- maria.js, line 567
Methods
-
<static> mixin(obj)
-
Mixes in the Node methods into any object.
Example 1
app.MyView = function() { hijos.Node.call(this); }; hijos.Node.mixin(app.MyView.prototype);Example 2
var obj = {}; hijos.Node.mixin(obj);Parameters:
Name Type Description objObject The object to become a
Node.- Source:
- maria.js, line 934
-
appendChild(newChild)
-
Adds
newChildas the last child of thisNode. IfnewChildis a child of anotherNodethennewChildis removed from that otherNodebefore appending to thisNode.var parent = new hijos.Node(); var child = new hijos.Leaf(); parent.appendChild(child); var child = new hijos.Node(); parent.appendChild(child);Parameters:
Name Type Description newChildObject The Leaf or Node object to append.
- Source:
- maria.js, line 837
-
destroy()
-
Call before your application code looses its last reference to the object. Generally this will be called for you by the destroy method of the containing
Nodeobject unless this object is not contained by anotherNode.- Source:
- maria.js, line 720
-
hasChildNodes() → {boolean}
-
Does this
Nodehave any children?- Source:
- maria.js, line 740
Returns:
trueif thisNodehas children. Otherwisefalse.- Type
- boolean
-
insertBefore(newChild, oldChild)
-
Inserts
newChildbeforeoldChild. IfoldChildisnullthen this is equivalent to appendingnewChild. IfnewChildis a child of anotherNodethennewChildis removed from that otherNodebefore appending to thisNode.var parent = new hijos.Node(); var child0 = new hijos.Leaf(); parent.insertBefore(child0, null); var child1 = new hijos.Node(); parent.insertBefore(child1, child0);Parameters:
Name Type Argument Description newChildObject The Leaf or Node object to insert.
oldChildObject | null <optional>
The child object to insert before.
- Source:
- maria.js, line 761
-
removeChild(oldChild)
-
Removes
oldChild.var parent = new hijos.Node(); var child = new hijos.Leaf(); parent.appendChild(child); parent.removeChild(child);Parameters:
Name Type Description oldChildObject The child object to remove.
- Source:
- maria.js, line 888
-
replaceChild(newChild, oldChild)
-
Replaces
oldChildwithnewChild. IfnewChildis a child of anotherNodethennewChildis removed from that otherNodebefore appending to thisNode.var parent = new hijos.Node(); var child0 = new hijos.Leaf(); parent.appendChild(child0); var child1 = new hijos.Node(); parent.replaceChild(child1, child0);Parameters:
Name Type Description newChildObject The Leaf or Node object to insert.
oldChildObject The child object to remove/replace.
- Source:
- maria.js, line 860