Skip to content
Snippets Groups Projects
index.js 7.57 MiB
Newer Older
  • Learn to ignore specific revisions
  • Hugo SUBTIL's avatar
    Hugo SUBTIL committed
          } else if (isObject(name)) {
            for (key in name) {
              if (!hasProp.call(name, key)) continue;
              val = name[key];
              if (isFunction(val)) {
                val = val.apply();
              }
              if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
                lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
              } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) {
                lastChild = this.dummy();
              } else if (isObject(val) && isEmpty(val)) {
                lastChild = this.element(key);
              } else if (!this.options.keepNullNodes && (val == null)) {
                lastChild = this.dummy();
              } else if (!this.options.separateArrayItems && Array.isArray(val)) {
                for (k = 0, len1 = val.length; k < len1; k++) {
                  item = val[k];
                  childNode = {};
                  childNode[key] = item;
                  lastChild = this.element(childNode);
                }
              } else if (isObject(val)) {
                if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) {
                  lastChild = this.element(val);
                } else {
                  lastChild = this.element(key);
                  lastChild.element(val);
                }
              } else {
                lastChild = this.element(key, val);
              }
            }
          } else if (!this.options.keepNullNodes && text === null) {
            lastChild = this.dummy();
          } else {
            if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
              lastChild = this.text(text);
            } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
              lastChild = this.cdata(text);
            } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
              lastChild = this.comment(text);
            } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
              lastChild = this.raw(text);
            } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
              lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
            } else {
              lastChild = this.node(name, attributes, text);
            }
          }
          if (lastChild == null) {
            throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo());
          }
          return lastChild;
        };
    
        XMLNode.prototype.insertBefore = function(name, attributes, text) {
          var child, i, newChild, refChild, removed;
          if (name != null ? name.type : void 0) {
            newChild = name;
            refChild = attributes;
            newChild.setParent(this);
            if (refChild) {
              i = children.indexOf(refChild);
              removed = children.splice(i);
              children.push(newChild);
              Array.prototype.push.apply(children, removed);
            } else {
              children.push(newChild);
            }
            return newChild;
          } else {
            if (this.isRoot) {
              throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
            }
            i = this.parent.children.indexOf(this);
            removed = this.parent.children.splice(i);
            child = this.parent.element(name, attributes, text);
            Array.prototype.push.apply(this.parent.children, removed);
            return child;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.insertAfter = function(name, attributes, text) {
          var child, i, removed;
          if (this.isRoot) {
            throw new Error("Cannot insert elements at root level. " + this.debugInfo(name));
          }
          i = this.parent.children.indexOf(this);
          removed = this.parent.children.splice(i + 1);
          child = this.parent.element(name, attributes, text);
          Array.prototype.push.apply(this.parent.children, removed);
          return child;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.remove = function() {
          var i, ref2;
          if (this.isRoot) {
            throw new Error("Cannot remove the root element. " + this.debugInfo());
          }
          i = this.parent.children.indexOf(this);
          [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2;
          return this.parent;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.node = function(name, attributes, text) {
          var child, ref2;
          if (name != null) {
            name = getValue(name);
          }
          attributes || (attributes = {});
          attributes = getValue(attributes);
          if (!isObject(attributes)) {
            ref2 = [attributes, text], text = ref2[0], attributes = ref2[1];
          }
          child = new XMLElement(this, name, attributes);
          if (text != null) {
            child.text(text);
          }
          this.children.push(child);
          return child;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.text = function(value) {
          var child;
          if (isObject(value)) {
            this.element(value);
          }
          child = new XMLText(this, value);
          this.children.push(child);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.cdata = function(value) {
          var child;
          child = new XMLCData(this, value);
          this.children.push(child);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.comment = function(value) {
          var child;
          child = new XMLComment(this, value);
          this.children.push(child);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.commentBefore = function(value) {
          var child, i, removed;
          i = this.parent.children.indexOf(this);
          removed = this.parent.children.splice(i);
          child = this.parent.comment(value);
          Array.prototype.push.apply(this.parent.children, removed);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.commentAfter = function(value) {
          var child, i, removed;
          i = this.parent.children.indexOf(this);
          removed = this.parent.children.splice(i + 1);
          child = this.parent.comment(value);
          Array.prototype.push.apply(this.parent.children, removed);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.raw = function(value) {
          var child;
          child = new XMLRaw(this, value);
          this.children.push(child);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.dummy = function() {
          var child;
          child = new XMLDummy(this);
          return child;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.instruction = function(target, value) {
          var insTarget, insValue, instruction, j, len;
          if (target != null) {
            target = getValue(target);
          }
          if (value != null) {
            value = getValue(value);
          }
          if (Array.isArray(target)) {
            for (j = 0, len = target.length; j < len; j++) {
              insTarget = target[j];
              this.instruction(insTarget);
            }
          } else if (isObject(target)) {
            for (insTarget in target) {
              if (!hasProp.call(target, insTarget)) continue;
              insValue = target[insTarget];
              this.instruction(insTarget, insValue);
            }
          } else {
            if (isFunction(value)) {
              value = value.apply();
            }
            instruction = new XMLProcessingInstruction(this, target, value);
            this.children.push(instruction);
          }
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.instructionBefore = function(target, value) {
          var child, i, removed;
          i = this.parent.children.indexOf(this);
          removed = this.parent.children.splice(i);
          child = this.parent.instruction(target, value);
          Array.prototype.push.apply(this.parent.children, removed);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.instructionAfter = function(target, value) {
          var child, i, removed;
          i = this.parent.children.indexOf(this);
          removed = this.parent.children.splice(i + 1);
          child = this.parent.instruction(target, value);
          Array.prototype.push.apply(this.parent.children, removed);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.declaration = function(version, encoding, standalone) {
          var doc, xmldec;
          doc = this.document();
          xmldec = new XMLDeclaration(doc, version, encoding, standalone);
          if (doc.children.length === 0) {
            doc.children.unshift(xmldec);
          } else if (doc.children[0].type === NodeType.Declaration) {
            doc.children[0] = xmldec;
          } else {
            doc.children.unshift(xmldec);
          }
          return doc.root() || doc;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.dtd = function(pubID, sysID) {
          var child, doc, doctype, i, j, k, len, len1, ref2, ref3;
          doc = this.document();
          doctype = new XMLDocType(doc, pubID, sysID);
          ref2 = doc.children;
          for (i = j = 0, len = ref2.length; j < len; i = ++j) {
            child = ref2[i];
            if (child.type === NodeType.DocType) {
              doc.children[i] = doctype;
              return doctype;
            }
          }
          ref3 = doc.children;
          for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) {
            child = ref3[i];
            if (child.isRoot) {
              doc.children.splice(i, 0, doctype);
              return doctype;
            }
          }
          doc.children.push(doctype);
          return doctype;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.up = function() {
          if (this.isRoot) {
            throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
          }
          return this.parent;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.root = function() {
          var node;
          node = this;
          while (node) {
            if (node.type === NodeType.Document) {
              return node.rootObject;
            } else if (node.isRoot) {
              return node;
            } else {
              node = node.parent;
            }
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.document = function() {
          var node;
          node = this;
          while (node) {
            if (node.type === NodeType.Document) {
              return node;
            } else {
              node = node.parent;
            }
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.end = function(options) {
          return this.document().end(options);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.prev = function() {
          var i;
          i = this.parent.children.indexOf(this);
          if (i < 1) {
            throw new Error("Already at the first node. " + this.debugInfo());
          }
          return this.parent.children[i - 1];
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.next = function() {
          var i;
          i = this.parent.children.indexOf(this);
          if (i === -1 || i === this.parent.children.length - 1) {
            throw new Error("Already at the last node. " + this.debugInfo());
          }
          return this.parent.children[i + 1];
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.importDocument = function(doc) {
          var clonedRoot;
          clonedRoot = doc.root().clone();
          clonedRoot.parent = this;
          clonedRoot.isRoot = false;
          this.children.push(clonedRoot);
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.debugInfo = function(name) {
          var ref2, ref3;
          name = name || this.name;
          if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) {
            return "";
          } else if (name == null) {
            return "parent: <" + this.parent.name + ">";
          } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) {
            return "node: <" + name + ">";
          } else {
            return "node: <" + name + ">, parent: <" + this.parent.name + ">";
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.ele = function(name, attributes, text) {
          return this.element(name, attributes, text);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.nod = function(name, attributes, text) {
          return this.node(name, attributes, text);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.txt = function(value) {
          return this.text(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.dat = function(value) {
          return this.cdata(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.com = function(value) {
          return this.comment(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.ins = function(target, value) {
          return this.instruction(target, value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.doc = function() {
          return this.document();
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.dec = function(version, encoding, standalone) {
          return this.declaration(version, encoding, standalone);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.e = function(name, attributes, text) {
          return this.element(name, attributes, text);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.n = function(name, attributes, text) {
          return this.node(name, attributes, text);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.t = function(value) {
          return this.text(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.d = function(value) {
          return this.cdata(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.c = function(value) {
          return this.comment(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.r = function(value) {
          return this.raw(value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.i = function(target, value) {
          return this.instruction(target, value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.u = function() {
          return this.up();
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.importXMLBuilder = function(doc) {
          return this.importDocument(doc);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.replaceChild = function(newChild, oldChild) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.removeChild = function(oldChild) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.appendChild = function(newChild) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.hasChildNodes = function() {
          return this.children.length !== 0;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.cloneNode = function(deep) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.normalize = function() {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isSupported = function(feature, version) {
          return true;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.hasAttributes = function() {
          return this.attribs.length !== 0;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.compareDocumentPosition = function(other) {
          var ref, res;
          ref = this;
          if (ref === other) {
            return 0;
          } else if (this.document() !== other.document()) {
            res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific;
            if (Math.random() < 0.5) {
              res |= DocumentPosition.Preceding;
            } else {
              res |= DocumentPosition.Following;
            }
            return res;
          } else if (ref.isAncestor(other)) {
            return DocumentPosition.Contains | DocumentPosition.Preceding;
          } else if (ref.isDescendant(other)) {
            return DocumentPosition.Contains | DocumentPosition.Following;
          } else if (ref.isPreceding(other)) {
            return DocumentPosition.Preceding;
          } else {
            return DocumentPosition.Following;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isSameNode = function(other) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.lookupPrefix = function(namespaceURI) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isDefaultNamespace = function(namespaceURI) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.lookupNamespaceURI = function(prefix) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isEqualNode = function(node) {
          var i, j, ref2;
          if (node.nodeType !== this.nodeType) {
            return false;
          }
          if (node.children.length !== this.children.length) {
            return false;
          }
          for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) {
            if (!this.children[i].isEqualNode(node.children[i])) {
              return false;
            }
          }
          return true;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.getFeature = function(feature, version) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.setUserData = function(key, data, handler) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.getUserData = function(key) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.contains = function(other) {
          if (!other) {
            return false;
          }
          return other === this || this.isDescendant(other);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isDescendant = function(node) {
          var child, isDescendantChild, j, len, ref2;
          ref2 = this.children;
          for (j = 0, len = ref2.length; j < len; j++) {
            child = ref2[j];
            if (node === child) {
              return true;
            }
            isDescendantChild = child.isDescendant(node);
            if (isDescendantChild) {
              return true;
            }
          }
          return false;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isAncestor = function(node) {
          return node.isDescendant(this);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.isPreceding = function(node) {
          var nodePos, thisPos;
          nodePos = this.treePosition(node);
          thisPos = this.treePosition(this);
          if (nodePos === -1 || thisPos === -1) {
            return false;
          } else {
            return nodePos < thisPos;
          }
        };
    
        XMLNode.prototype.isFollowing = function(node) {
          var nodePos, thisPos;
          nodePos = this.treePosition(node);
          thisPos = this.treePosition(this);
          if (nodePos === -1 || thisPos === -1) {
            return false;
          } else {
            return nodePos > thisPos;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.treePosition = function(node) {
          var found, pos;
          pos = 0;
          found = false;
          this.foreachTreeNode(this.document(), function(childNode) {
            pos++;
            if (!found && childNode === node) {
              return found = true;
            }
          });
          if (found) {
            return pos;
          } else {
            return -1;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLNode.prototype.foreachTreeNode = function(node, func) {
          var child, j, len, ref2, res;
          node || (node = this.document());
          ref2 = node.children;
          for (j = 0, len = ref2.length; j < len; j++) {
            child = ref2[j];
            if (res = func(child)) {
              return res;
            } else {
              res = this.foreachTreeNode(child, func);
              if (res) {
                return res;
              }
            }
          }
        };
    
        return XMLNode;
    
      })();
    
    }).call(this);
    
    /* 1530 */
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    // Generated by CoffeeScript 1.12.7
    (function() {
      var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref,
        extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
        hasProp = {}.hasOwnProperty;
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      ref = __webpack_require__(1523), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue;
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      XMLNode = __webpack_require__(1529);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      NodeType = __webpack_require__(1531);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      XMLAttribute = __webpack_require__(1532);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      XMLNamedNodeMap = __webpack_require__(1533);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      module.exports = XMLElement = (function(superClass) {
        extend(XMLElement, superClass);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        function XMLElement(parent, name, attributes) {
          var child, j, len, ref1;
          XMLElement.__super__.constructor.call(this, parent);
          if (name == null) {
            throw new Error("Missing element name. " + this.debugInfo());
          }
          this.name = this.stringify.name(name);
          this.type = NodeType.Element;
          this.attribs = {};
          this.schemaTypeInfo = null;
          if (attributes != null) {
            this.attribute(attributes);
          }
          if (parent.type === NodeType.Document) {
            this.isRoot = true;
            this.documentObject = parent;
            parent.rootObject = this;
            if (parent.children) {
              ref1 = parent.children;
              for (j = 0, len = ref1.length; j < len; j++) {
                child = ref1[j];
                if (child.type === NodeType.DocType) {
                  child.name = this.name;
                  break;
                }
              }
            }
          }
        }
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'tagName', {
          get: function() {
            return this.name;
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'namespaceURI', {
          get: function() {
            return '';
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'prefix', {
          get: function() {
            return '';
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'localName', {
          get: function() {
            return this.name;
          }
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'id', {
          get: function() {
            throw new Error("This DOM method is not implemented." + this.debugInfo());
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'className', {
          get: function() {
            throw new Error("This DOM method is not implemented." + this.debugInfo());
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'classList', {
          get: function() {
            throw new Error("This DOM method is not implemented." + this.debugInfo());
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLElement.prototype, 'attributes', {
          get: function() {
            if (!this.attributeMap || !this.attributeMap.nodes) {
              this.attributeMap = new XMLNamedNodeMap(this.attribs);
            }
            return this.attributeMap;
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.clone = function() {
          var att, attName, clonedSelf, ref1;
          clonedSelf = Object.create(this);
          if (clonedSelf.isRoot) {
            clonedSelf.documentObject = null;
          }
          clonedSelf.attribs = {};
          ref1 = this.attribs;
          for (attName in ref1) {
            if (!hasProp.call(ref1, attName)) continue;
            att = ref1[attName];
            clonedSelf.attribs[attName] = att.clone();
          }
          clonedSelf.children = [];
          this.children.forEach(function(child) {
            var clonedChild;
            clonedChild = child.clone();
            clonedChild.parent = clonedSelf;
            return clonedSelf.children.push(clonedChild);
          });
          return clonedSelf;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.attribute = function(name, value) {
          var attName, attValue;
          if (name != null) {
            name = getValue(name);
          }
          if (isObject(name)) {
            for (attName in name) {
              if (!hasProp.call(name, attName)) continue;
              attValue = name[attName];
              this.attribute(attName, attValue);
            }
          } else {
            if (isFunction(value)) {
              value = value.apply();
            }
            if (this.options.keepNullAttributes && (value == null)) {
              this.attribs[name] = new XMLAttribute(this, name, "");
            } else if (value != null) {
              this.attribs[name] = new XMLAttribute(this, name, value);
            }
          }
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.removeAttribute = function(name) {
          var attName, j, len;
          if (name == null) {
            throw new Error("Missing attribute name. " + this.debugInfo());
          }
          name = getValue(name);
          if (Array.isArray(name)) {
            for (j = 0, len = name.length; j < len; j++) {
              attName = name[j];
              delete this.attribs[attName];
            }
          } else {
            delete this.attribs[name];
          }
          return this;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.toString = function(options) {
          return this.options.writer.element(this, this.options.writer.filterOptions(options));
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.att = function(name, value) {
          return this.attribute(name, value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.a = function(name, value) {
          return this.attribute(name, value);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getAttribute = function(name) {
          if (this.attribs.hasOwnProperty(name)) {
            return this.attribs[name].value;
          } else {
            return null;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setAttribute = function(name, value) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getAttributeNode = function(name) {
          if (this.attribs.hasOwnProperty(name)) {
            return this.attribs[name];
          } else {
            return null;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setAttributeNode = function(newAttr) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.removeAttributeNode = function(oldAttr) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getElementsByTagName = function(name) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setAttributeNodeNS = function(newAttr) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.hasAttribute = function(name) {
          return this.attribs.hasOwnProperty(name);
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setIdAttribute = function(name, isId) {
          if (this.attribs.hasOwnProperty(name)) {
            return this.attribs[name].isId;
          } else {
            return isId;
          }
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getElementsByTagName = function(tagname) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.getElementsByClassName = function(classNames) {
          throw new Error("This DOM method is not implemented." + this.debugInfo());
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        XMLElement.prototype.isEqualNode = function(node) {
          var i, j, ref1;
          if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) {
            return false;
          }
          if (node.namespaceURI !== this.namespaceURI) {
            return false;
          }
          if (node.prefix !== this.prefix) {
            return false;
          }
          if (node.localName !== this.localName) {
            return false;
          }
          if (node.attribs.length !== this.attribs.length) {
            return false;
          }
          for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) {
            if (!this.attribs[i].isEqualNode(node.attribs[i])) {
              return false;
            }
          }
          return true;
        };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        return XMLElement;
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      })(XMLNode);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    }).call(this);
    
    /* 1531 */
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    /***/ (function(module) {
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    // Generated by CoffeeScript 1.12.7
    (function() {
      module.exports = {
        Element: 1,
        Attribute: 2,
        Text: 3,
        CData: 4,
        EntityReference: 5,
        EntityDeclaration: 6,
        ProcessingInstruction: 7,
        Comment: 8,
        Document: 9,
        DocType: 10,
        DocumentFragment: 11,
        NotationDeclaration: 12,
        Declaration: 201,
        Raw: 202,
        AttributeDeclaration: 203,
        ElementDeclaration: 204,
        Dummy: 205
      };
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    }).call(this);
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    /***/ }),
    
    /* 1532 */
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
    // Generated by CoffeeScript 1.12.7
    (function() {
      var NodeType, XMLAttribute, XMLNode;
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      NodeType = __webpack_require__(1531);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
      XMLNode = __webpack_require__(1529);
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
      module.exports = XMLAttribute = (function() {
        function XMLAttribute(parent, name, value) {
          this.parent = parent;
          if (this.parent) {
            this.options = this.parent.options;
            this.stringify = this.parent.stringify;
          }
          if (name == null) {
            throw new Error("Missing attribute name. " + this.debugInfo(name));
          }
          this.name = this.stringify.name(name);
          this.value = this.stringify.attValue(value);
          this.type = NodeType.Attribute;
          this.isId = false;
          this.schemaTypeInfo = null;
        }
    
        Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
          get: function() {
            return this.type;
          }
        });
    
        Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
          get: function() {
            return this.parent;
          }
        });
    
        Object.defineProperty(XMLAttribute.prototype, 'textContent', {
          get: function() {
            return this.value;
          },
          set: function(value) {
            return this.value = value || '';
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
          get: function() {
            return '';
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLAttribute.prototype, 'prefix', {
          get: function() {
            return '';
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed
    
    
    Hugo SUBTIL's avatar
    Hugo SUBTIL committed
        Object.defineProperty(XMLAttribute.prototype, 'localName', {
          get: function() {
            return this.name;
          }
        });
    
    Hugo NOUTS's avatar
    Hugo NOUTS committed