File: get_ancestor.js

package info (click to toggle)
pageedit 1.9.20%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,508 kB
  • sloc: ansic: 31,777; cpp: 12,496; python: 1,415; makefile: 106; javascript: 87; sh: 21
file content (14 lines) | stat: -rw-r--r-- 486 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// From the current node, walk up the parent hierarchy until find a matching
// element matching one of the specified node names.
function get_ancestor(startNode, targetNodeNames) {
    var found = false;
    while( found == false && node != null ) {
        for( var i = 0; i < 1; i++ ) {
            if ( node.nodeName.toLowerCase() == targetNodeNames[i].toLowerCase() ) {
                return node;
            }
        }
        node = node.parentNode;
    }
    return node;
};