diff --git a/src/Document.js b/src/Document.js index 6f6066a..e8befaa 100644 --- a/src/Document.js +++ b/src/Document.js @@ -1,5 +1,3 @@ -/* eslint-disable no-dupe-class-members */ - const libxmljs = require('libxmljs'); const utils = require('./utils'); @@ -64,11 +62,7 @@ return this._original.childNodes(); } - encoding() { - return this._original.encoding(); - } - - encoding(enc) { + encoding(enc = null) { return this._original.encoding(enc); } @@ -141,13 +135,7 @@ return this._original.rngValidate(rng); } - root() { - this.assertNoContentError(); - - return this._original.root(); - } - - root(node) { + root(node = null) { this.assertNoContentError(); return this._original.root(node); @@ -157,6 +145,17 @@ return this._original.setDtd(name, ext, sys); } + setNamespace(alias, url) { + if (typeof alias !== 'string') throw new Error('alias must be a string.'); + if (typeof url !== 'string') throw new Error('url must be a string.'); + if (!utils.isValidURL(url)) throw new Error('url is not a valid URL.'); + + this.namespace = { + alias, + url, + }; + } + toString(formatting = true) { return this._original.toString(formatting); }