Class: Node

hijos. Node

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

Properties:
Name Type Description
hijos.Node.superConstructor
Source:
  • maria.js, line 663

<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 Leaf of this object. Null if this object is not the child of any Node or this object is the last child of a Node.

Inherited From:
Source:
  • maria.js, line 569

<readonly> parentNode :hijos.Leaf

The parent Node of this object. Null if this object is not the child of any Node.

Inherited From:
Source:
  • maria.js, line 565

<readonly> previousSibling :hijos.Leaf

The previous sibling Leaf of this object. Null if this object is not the child of any Node or this object is the first child of a Node.

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
obj Object

The object to become a Node.

Source:
  • maria.js, line 934

appendChild(newChild)

Adds newChild as the last child of this Node. If newChild is a child of another Node then newChild is removed from that other Node before appending to this Node.

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
newChild Object

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 Node object unless this object is not contained by another Node.

Source:
  • maria.js, line 720

hasChildNodes() → {boolean}

Does this Node have any children?

Source:
  • maria.js, line 740
Returns:

true if this Node has children. Otherwise false.

Type
boolean

insertBefore(newChild, oldChild)

Inserts newChild before oldChild. If oldChild is null then this is equivalent to appending newChild. If newChild is a child of another Node then newChild is removed from that other Node before appending to this Node.

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
newChild Object

The Leaf or Node object to insert.

oldChild Object | 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
oldChild Object

The child object to remove.

Source:
  • maria.js, line 888

replaceChild(newChild, oldChild)

Replaces oldChild with newChild. If newChild is a child of another Node then newChild is removed from that other Node before appending to this Node.

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
newChild Object

The Leaf or Node object to insert.

oldChild Object

The child object to remove/replace.

Source:
  • maria.js, line 860