"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.XmlDocument = void 0; const XmlElement_js_1 = require("./XmlElement.js"); const XmlNode_js_1 = require("./XmlNode.js"); /** * Represents an XML document. All elements within the document are descendants * of this node. */ class XmlDocument extends XmlNode_js_1.XmlNode { constructor(children = []) { super(); this.children = children; } get document() { return this; } /** * Root element of this document, or `null` if this document is empty. */ get root() { for (let child of this.children) { if (child instanceof XmlElement_js_1.XmlElement) { return child; } } return null; } /** * Text content of this document and all its descendants. */ get text() { return this.children .map(child => 'text' in child ? child.text : '') .join(''); } get type() { return XmlNode_js_1.XmlNode.TYPE_DOCUMENT; } toJSON() { return Object.assign(XmlNode_js_1.XmlNode.prototype.toJSON.call(this), { children: this.children.map(child => child.toJSON()), }); } } exports.XmlDocument = XmlDocument; //# sourceMappingURL=XmlDocument.js.map