text: // DOM utility methods used by Rangy
  /* build:replaceWith(api) */rangy/* build:replaceEnd */.createCoreModule("DomUtil", [], function(api, module) {
      var UNDEF = "undefined";
      var util = api.util;
  
      var arrayContains = /*Array.prototype.indexOf ?
  */
          function(arr, val) {
              return arr.indexOf(val) > -1;
          };/*
          }:*/
  
      // Opera 11 puts HTML elements in the null namespace, it seems, and IE 7 has undefined namespaceURI
      function isHtmlNamespace(node) {
          var ns;
          return typeof node.namespaceURI == UNDEF || ((ns = node.namespaceURI) === null || ns == "http://www.w3.org/1999/xhtml");
      }
  
      function parentElement(node) {
          var parent = node.parentNode;
          return (parent.nodeType == 1) ? parent : null;
      }
  
      function getNodeIndex(node) {
          var i = 0;
          while( (node = node.previousSibling) ) {
              ++i;
          }
          return i;
      }
  
      function getNodeLength(node) {
          switch (node.nodeType) {
              case 7:
              case 10:
                  return 0;
              case 3:
              case 8:
                  return node.length;
              default:
                  return node.childNodes.length;
          }
      }
  
      function getCommonAncestor(node1, node2) {
          var ancestors = [], n;
          for (n = node1; n; n = n.parentNode) {
              ancestors.push(n);
          }
  
          for (n = node2; n; n = n.parentNode) {
              if (arrayContains(ancestors, n)) {
                  return n;
              }
          }
  
          return null;
      }
  
      function isAncestorOf(ancestor, descendant, selfIsAncestor) {
          var n = selfIsAncestor ? descendant : descendant.parentNode;
          while (n) {
              if (n === ancestor) {
                  return true;
              } else {
                  n = n.parentNode;
              }
          }
          return false;
      }
  
      function isOrIsAncestorOf(ancestor, descendant) {
          return isAncestorOf(ancestor, descendant, true);
      }
  
      function getClosestAncestorIn(node, ancestor, selfIsAncestor) {
          var p, n = selfIsAncestor ? node : node.parentNode;
          while (n) {
              p = n.parentNode;
              if (p === ancestor) {
                  return n;
              }
              n = p;
          }
          return null;
      }
  
      function isCharacterDataNode(node) {
          var t = node.nodeType;
          return t == 3 || t == 4 || t == 8 ; // Text, CDataSection or Comment
      }
  
      function insertAfter(node, precedingNode) {
          var nextNode = precedingNode.nextSibling, parent = precedingNode.parentNode;
          if (nextNode) {
              parent.insertBefore(node, nextNode);
          } else {
              parent.appendChild(node);
          }
          return node;
      }
  
      // Note that we cannot use splitText() because it is bugridden in IE 9.
      function splitDataNode(node, index, positionsToPreserve) {
          var newNode = node.cloneNode(false);
          newNode.deleteData(0, index);
          node.deleteData(index, node.length - index);
          insertAfter(newNode, node);
  
          // Preserve positions
          if (positionsToPreserve) {
              for (var i = 0, position; position = positionsToPreserve[i++]; ) {
                  // Handle case where position was inside the portion of node after the split point
                  if (position.node == node && position.offset > index) {
                      position.node = newNode;
                      position.offset -= index;
                  }
                  // Handle the case where the position is a node offset within node's parent
                  else if (position.node == node.parentNode && position.offset > getNodeIndex(node)) {
                      ++position.offset;
                  }
              }
          }
          return newNode;
      }
  
      function getDocument(node) {
          if (node.nodeType == 9) {
              return node;
          } else if (typeof node.ownerDocument != UNDEF) {
              return node.ownerDocument;
          }
      }
  
      function getWindow(node) {
          var doc = getDocument(node);
          if (typeof doc.defaultView != UNDEF) {
              return doc.defaultView;
          }
      }
  
      // This looks bad. Is it worth it?
      function isWindow(obj) {
          return obj && util.isHostMethod(obj, "setTimeout") && util.isHostObject(obj, "document");
      }
  
      function getContentDocument(obj, module, methodName) {
          var doc;
  
          if (!obj) {
              doc = document;
          }
  
          // Test if a DOM node has been passed and obtain a document object for it if so
          else if (util.isHostProperty(obj, "nodeType")) {
              doc = getDocument(obj);
          }
  
          // Test if the doc parameter appears to be a Window object
          else if (isWindow(obj)) {
              doc = obj.document;
          }
  
          return doc;
      }
  
      function getRootContainer(node) {
          var parent;
          while ( (parent = node.parentNode) ) {
              node = parent;
          }
          return node;
      }
  
      function comparePoints(nodeA, offsetA, nodeB, offsetB) {
          // See http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Comparing
          var nodeC, root, childA, childB, n;
          if (nodeA == nodeB) {
              // Case 1: nodes are the same
              return offsetA === offsetB ? 0 : (offsetA < offsetB) ? -1 : 1;
          } else if ( (nodeC = getClosestAncestorIn(nodeB, nodeA, true)) ) {
              // Case 2: node C (container B or an ancestor) is a child node of A
              return offsetA <= getNodeIndex(nodeC) ? -1 : 1;
          } else if ( (nodeC = getClosestAncestorIn(nodeA, nodeB, true)) ) {
              // Case 3: node C (container A or an ancestor) is a child node of B
              return getNodeIndex(nodeC) < offsetB  ? -1 : 1;
          } else {
              root = getCommonAncestor(nodeA, nodeB);
  
              // Case 4: containers are siblings or descendants of siblings
              childA = (nodeA === root) ? root : getClosestAncestorIn(nodeA, root, true);
              childB = (nodeB === root) ? root : getClosestAncestorIn(nodeB, root, true);
  
                  n = root.firstChild;
                  while (n) {
                      if (n === childA) {
                          return -1;
                      } else if (n === childB) {
                          return 1;
                      }
                      n = n.nextSibling;
                  }
          }
      }
  
      /*----------------------------------------------------------------------------------------------------------------*/
  
      var getComputedStyleProperty;
          getComputedStyleProperty = function(el, propName) {
              return getWindow(el).getComputedStyle(el, null)[propName];
          };
  
      function NodeIterator(root) {
          this.root = root;
          this._next = root;
      }
  
      NodeIterator.prototype = {
          _current: null,
  
          next: function() {
              var n = this._current = this._next;
              var child, next;
              if (this._current) {
                  child = n.firstChild;
                  if (child) {
                      this._next = child;
                  } else {
                      next = null;
                      while ((n !== this.root) && !(next = n.nextSibling)) {
                          n = n.parentNode;
                      }
                      this._next = next;
                  }
              }
              return this._current;
          },
  
          detach: function() {
              this._current = this._next = this.root = null;
          }
      };
  
      function createIterator(root) {
          return new NodeIterator(root);
      }
  
      function DomPosition(node, offset) {
          this.node = node;
          this.offset = offset;
      }
  
      DomPosition.prototype = {
          equals: function(pos) {
              return !!pos && this.node === pos.node && this.offset == pos.offset;
          }
      };
  
      api.dom = {
          arrayContains: arrayContains,
          isHtmlNamespace: isHtmlNamespace,
          parentElement: parentElement,
          getNodeIndex: getNodeIndex,
          getNodeLength: getNodeLength,
          getCommonAncestor: getCommonAncestor,
          isAncestorOf: isAncestorOf,
          isOrIsAncestorOf: isOrIsAncestorOf,
          getClosestAncestorIn: getClosestAncestorIn,
          isCharacterDataNode: isCharacterDataNode,
          insertAfter: insertAfter,
          splitDataNode: splitDataNode,
          getDocument: getDocument,
          getWindow: getWindow,
          getBody: util.getBody,
          isWindow: isWindow,
          getContentDocument: getContentDocument,
          getRootContainer: getRootContainer,
          comparePoints: comparePoints,
          getComputedStyleProperty: getComputedStyleProperty,
          createIterator: createIterator,
          DomPosition: DomPosition
      };
  });