src/http/get-index/ssr.js
/**
 * Compare the position of one node against another node in any other document.
 * The return value is a bitmask with the following values:
 *
 * Document order:
 * > There is an ordering, document order, defined on all the nodes in the
 * > document corresponding to the order in which the first character of the
 * > XML representation of each node occurs in the XML representation of the
 * > document after expansion of general entities. Thus, the document element
 * > node will be the first node. Element nodes occur before their children.
 * > Thus, document order orders element nodes in order of the occurrence of
 * > their start-tag in the XML (after expansion of entities). The attribute
 * > nodes of an element occur after the element and before its children. The
 * > relative order of attribute nodes is implementation-dependent./
 *
 * Source:
 * http://www.w3.org/TR/DOM-Level-3-Core/glossary.html#dt-document-order
 *
 * @param nodeA The first node to use in the comparison
 * @param nodeB The second node to use in the comparison
 * @returns A bitmask describing the input nodes' relative position.
 *
 * See http://dom.spec.whatwg.org/#dom-node-comparedocumentposition for
 * a description of these values.
 */
Compare the position of one node against another node in any other document.
The return value is a bitmask with the following values.

Document order:
> There is an ordering, document order, defined on all the nodes in the
> document corresponding to the order in which the first character of the
> XML representation of each node occurs in the XML representation of the
> document after expansion of general entities. Thus, the document element
> node will be the first node. Element nodes occur before their children.
> Thus, document order orders element nodes in order of the occurrence of
> their start-tag in the XML (after expansion of entities). The attribute
> nodes of an element occur after the element and before its children. The
> relative order of attribute nodes is implementation-dependent.



@param nodeA The first node to use in the comparison
@param nodeB The second node to use in the comparison
@returns A bitmask describing the input nodes' relative position.


Compare the position of one node against another node in any other document . The return value is a bitmask with the following values . Document order : > There is an ordering document order defined on all the nodes in the > document corresponding to the order in which the first character of the > XML representation of each node occurs in the XML representation of the > document after expansion of general entities . Thus the document element > node will be the first node . Element nodes occur before their children . > Thus document order orders element nodes in order of the occurrence of > their start - tag in the XML ( after expansion of entities ) . The attribute > nodes of an element occur after the element and before its children . The > relative order of attribute nodes is implementation - dependent . @param nodeA The first node to use in the comparison @param nodeB The second node to use in the comparison @returns A bitmask describing the input nodes ' relative position .
function compareDocumentPosition(nodeA, nodeB) {
  var aParents = [];
  var bParents = [];
  if (nodeA === nodeB) {
    return 0;
  }
  var current = domhandler_1$1.hasChildren(nodeA) ? nodeA : nodeA.parent;
  while (current) {
    aParents.unshift(current);
    current = current.parent;
  }
  current = domhandler_1$1.hasChildren(nodeB) ? nodeB : nodeB.parent;
  while (current) {
    bParents.unshift(current);
    current = current.parent;
  }
  var maxIdx = Math.min(aParents.length, bParents.length);
  var idx = 0;
  while (idx < maxIdx && aParents[idx] === bParents[idx]) {
    idx++;
  }
  if (idx === 0) {
    return 1 ;
  }
  var sharedParent = aParents[idx - 1];
  var siblings = sharedParent.children;
  var aSibling = aParents[idx];
  var bSibling = bParents[idx];
  if (siblings.indexOf(aSibling) > siblings.indexOf(bSibling)) {
    if (sharedParent === nodeB) {
      return 4  | 16 ;
    }
    return 4 ;
  }
  if (sharedParent === nodeA) {
    return 2  | 8 ;
  }
  return 2 ;
}
function compareDocumentPosition ( nodeA , nodeB ) { var aParents = [ ] ; var bParents = [ ] ; if ( nodeA === nodeB ) { return 0 ; } var current = domhandler_1$1 . hasChildren ( nodeA ) ? nodeA : nodeA . parent ; while ( current ) { aParents . unshift ( current ) ; current = current . parent ; } current = domhandler_1$1 . hasChildren ( nodeB ) ? nodeB : nodeB . parent ; while ( current ) { bParents . unshift ( current ) ; current = current . parent ; } var maxIdx = Math . min ( aParents . length , bParents . length ) ; var idx = 0 ; while ( idx < maxIdx && aParents [ idx ] === bParents [ idx ] ) { idx ++ ; } if ( idx === 0 ) { return 1 ; } var sharedParent = aParents [ idx - 1 ] ; var siblings = sharedParent . children ; var aSibling = aParents [ idx ] ; var bSibling = bParents [ idx ] ; if ( siblings . indexOf ( aSibling ) > siblings . indexOf ( bSibling ) ) { if ( sharedParent === nodeB ) { return 4 | 16 ; } return 4 ; } if ( sharedParent === nodeA ) { return 2 | 8 ; } return 2 ; }
Compare the position of one node against another node in any other document.
Compare the position of one node against another node in any other document .
/* DISCONNECTED */ /* FOLLOWING */ /* CONTAINED_BY */ /* FOLLOWING */ /* PRECEDING */ /* CONTAINS */ /* PRECEDING */