Node manipulation


Removes all children of node. This method does not rely on the childNodes array and is therefore always safe. Note that if the node being emptied is subject to periodical dynamic node addition, nodes that happen to be added while the function is executing will also be removed.

pergola.attribute(element, list[, ns])

The list object specifies one or more attributes in the namespace vocabulary (attribute names containing illegal characters for JavaScript variable names must be specified as strings, e.g. "font-size") to be set for element. If specified, ns is a string or false. If not specified –ease of use priority given to SVG– setAttributeNS(null, ...) is used; if element is an HTML element, ns must be set to false, and setAttribute() is used; if ns is a namespace URI, setAttributeNS(ns, ...) is used. Examples:

 pergola.attribute(SVG <text> element, {x : value, y : value, "font-size" : value});
  pergola.attribute(HTML <div> element, {width : value, height : value, style : value}, false);
  pergola.attribute(element in some namespace, {attribute name : value, attribute name : value}, some namespace URI);

Note: you only need to use this method to add or modify attributes of an existing element. When creating elements you specify the attributes directly in the object passed to the DOM node builder.