src/lib/Parser.js
/**
  Adds the given _text_ to the document, either by appending it to a preceding
  `XmlText` node (if possible) or by creating a new `XmlText` node.

  @param {string} text
  */
Adds the given _text_ to the document, either by appending it to a preceding
`XmlText` node (if possible) or by creating a new `XmlText` node.
Adds the given _text_ to the document either by appending it to a preceding ` XmlText ` node ( if possible ) or by creating a new ` XmlText ` node .
addText(text) {
    let { children } = this.currentNode;
    if (children.length > 0) {
      let prevNode = children[children.length - 1];
      if (prevNode instanceof XmlText) {
        prevNode.text += text;
        return;
      }
    }
    this.addNode(new XmlText(text));
  }
addText ( text ) { let { children } = this . currentNode ; if ( children . length > 0 ) { let prevNode = children [ children . length - 1 ] ; if ( prevNode instanceof XmlText ) { prevNode . text += text ; return ; } } this . addNode ( new XmlText ( text ) ) ; }
Adds the given _text_ to the document, either by appending it to a preceding
`XmlText` node (if possible) or by creating a new `XmlText` node.
Adds the given _text_ to the document either by appending it to a preceding ` XmlText ` node ( if possible ) or by creating a new ` XmlText ` node .
// The previous node is a text node, so we can append to it and avoid // creating another node.