LzDataElement

出自OpenFace

跳转到: 导航, 搜索

目录

LzDataElement

A node of hierarchical data. Extends LzDataNode

An LzDataElement represents a node a in a hierarchical dataset. An LzDataElement can contain other LzDataElements, or LzDataText, which represents a text node. See the example on LzDataNode.

Attributes

Name       Usage      Type (Tag)     Type (JS)       Default       Category

attributes      JS only     Object                           setter

         The dictionary of attributes for this node.

childNodes     JS only      Array of LzDataNode                    setter

         An array of children of this node

nodeName     JS only      String                          setter

         The name of this node.

Attributes inherited from LzDataNode

nodeType, ownerDocument, parentNode

Methods

appendChild()

LzDataElement.appendChild(newChild)

Adds a child to this node's list of childNodes Parameters Name Type Desc newChild LzDataNode The LzDataNode to add. Returns Type Desc LzDataNode The newChild.

cloneNode()

LzDataElement.cloneNode(deep)

Returns a copy of this node. Parameters Name Type Desc deep Boolean If true, the children of this node will be part of the new node Returns Type Desc LzDataNode A copy of this node.

constructor()

LzDataElement(name, attributes, children)

This object represents a hierarchical data node. Parameters Name Type Desc name String The name for this node. attributes Object A optional dictionary of attributes for this node. children [LzDataNode] An optional array of children for this node

getAttr()

LzDataElement.getAttr(name)

Returns the value for the give attribute Parameters Name Type Desc name String The name of the attribute whose value to return Returns Type Desc String The value for the given attribute

getElementsByTagName()

LzDataElement.getElementsByTagName(name)

Returns a list of the childNodes of this node which have a given name Parameters Name Type Desc name String The name of the node to look for. Returns Type Desc [LzDataNode] A list of childNodes which have the given name.

getFirstChild()

LzDataElement.getFirstChild()

Returns the first child of this node. Returns Type Desc LzDataNode The first child of this node

getLastChild()

LzDataElement.getLastChild()

Returns the last child of this node. Returns Type Desc LzDataNode The last child of this node

getOffset()

LzDataElement.getOffset()

gets offset of node in parent's childNodes array Returns Type Desc number

handleDocumentChange()

LzDataElement.handleDocumentChange(what, who, type)

Nodes call this method on their ownerDocument whenever they change in any way. This method sends the onDocumentChange event, which triggers datapointer updates Parameters Name Type Desc what String A description of what changed. who LzDataNode The node that changed. type Number private

hasAttr()

LzDataElement.hasAttr(name)

Tests whether or not this node has a given attribute. Parameters Name Type Desc name String The name of the attribute to test Returns Type Desc Boolean If true, the named attribute is present.

hasChildNodes()

LzDataElement.hasChildNodes()

Tests whether or not this node has child nodes. Returns Type Desc Boolean If true, this node has child nodes.

insertBefore()

LzDataElement.insertBefore(newChild, refChild)

Inserts the given LzDataNode before another node in this node's childNodes Parameters Name Type Desc newChild LzDataNode the LzDataNode to insert refChild LzDataNode the LzDataNode to insert newChild before Returns Type Desc LzDataElement The new child, or null if the refChild wasn't found

makeNodeList()

LzDataElement.makeNodeList(count, name)

Returns a list of empty nodes, each named 'name'. Parameters Name Type Desc count Number how many nodes to create. name String the name for each node Returns Type Desc Array list of new nodes.

removeAttr()

LzDataElement.removeAttr(name)

Removes the named attribute Parameters Name Type Desc name String The name of the attribute to remove.

removeChild()

LzDataElement.removeChild(oldChild)

Removes a given node from this node's childNodes Parameters Name Type Desc oldChild LzDataNode The LzDataNode to remove Returns Type Desc LzDataNode The removed child, or null if the oldChild was not found

replaceChild()

LzDataElement.replaceChild(newChild, oldChild)

Replaces a given LzDataNode in this node's childNodes with a new one. Parameters Name Type Desc newChild LzDataNode the LzDataNode to add oldChild LzDataNode the LzDataNode to be replaced by the newChild Returns Type Desc LzDataElement The new child, or null if the oldChild wasn't found

serialize()

LzDataElement.serialize()

Returns this node as a string of xml. Returns Type Desc String The string serialization of this node.

setAttr()

LzDataElement.setAttr(name, value)

Sets the given attribute to the given value Parameters Name Type Desc name String The name of the attribute to set. value String The value for the attribute.

setAttrs()

LzDataElement.setAttrs(attrs)

Sets the attributes of this node to the given Object. Parameters Name Type Desc attrs Object The object to use as the attrs for this node.

setChildNodes()

LzDataElement.setChildNodes(children)

Sets the children of this node to the given array. Parameters Name Type Desc children [LzDataNode] An array of LzDataNodes to be the new children of this node

setNodeName()

LzDataElement.setNodeName(name)

Sets the name of this node. Parameters Name Type Desc name String The new name for this node

valueToElement()

LzDataElement.valueToElement(o)

Get LzDataElement representation of primitive type, array, or object value. Parameters Name Type Desc o None

Methods inherited from LzDataNode

childOf, getNextSibling, getPreviousSibling, setOwnerDocument, stringToLzData