File: set_ancestor_attribute.js

package info (click to toggle)
pageedit 2.4.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,956 kB
  • sloc: ansic: 31,806; cpp: 15,036; python: 1,141; javascript: 87; sh: 13; makefile: 7
file content (13 lines) | stat: -rw-r--r-- 504 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
// Uses get_ancestor.js

// From the current node, walk up the parent hierarchy until find a matching
// element matching one of the specified node names. If found set the value
// of the named attribute.
function set_ancestor_attribute(startNode, targetNodes, attributeName, attributeValue) {
    var ancestorNode = get_ancestor(startNode, targetNodes);
    if ( ancestorNode != null) {
        ancestorNode.setAttribute( attributeName, attributeValue );
        return true;
    }
    return false;
};