Class Node


class Node
Extends the native Node class with additional functionality.

Not available in Internet Exporer which don’t have a Node class.

See http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html#ID-1950641247.

Authors:
Henrik Lindqvist <henrik.lindqvist@llamalab.com>
Defined in XPath.js

Function Summary
Compares a node with this node with regard to their position in the document and according to the document order.
boolean contains(Node n)
Check if this node contains another node.

Function Details

function compareDocumentPosition

number compareDocumentPosition(Node n)
Compares a node with this node with regard to their position in the document and according to the document order.

When comparing two attribute nodes; 32 is returned if they have the same ownerElement, otherwise 0. This is probably not standard, but it’s what Firefox return, so we do the same.

 DOCUMENT_POSITION_DISCONNECTED            = 1;
 DOCUMENT_POSITION_PRECEDING               = 2;
 DOCUMENT_POSITION_FOLLOWING               = 4;
 DOCUMENT_POSITION_CONTAINS                = 8;
 DOCUMENT_POSITION_IS_CONTAINED            = 16;
 DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
 

See http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html#Node3-compareDocumentPosition.

Parameters:
n - node to compare against.
Returns:
0 for nodes are equals or a number with some of the above bits set.

function contains

boolean contains(Node n)
Check if this node contains another node.
Parameters:
n - node to compare against.
Returns:
true if this node cotains node n.