UNPKG

libxmljs

Version:

libxml bindings for v8 javascript engine

71 lines 2.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var libxml = require("../index"); module.exports.basic = function (assert) { var _a; var doc = libxml.Document(); var elem = doc.node("name"); elem.attr({ to: "wongfoo" }); assert.equal("wongfoo", (_a = elem.getAttribute("to")) === null || _a === void 0 ? void 0 : _a.value()); assert.done(); }; module.exports.null = function (assert) { var doc = libxml.Document(); var elem = doc.node("name"); assert.equal(null, elem.getAttribute("to")); assert.done(); }; module.exports.assign_object = function (assert) { var _a; var doc = libxml.Document(); var elem = doc.node("name"); elem.attr({ to: "wongfoo" }); assert.equal("wongfoo", (_a = elem.getAttribute("to")) === null || _a === void 0 ? void 0 : _a.value()); assert.done(); }; module.exports.change = function (assert) { var _a, _b; var doc = libxml.Document(); var elem = doc.node("name"); elem.attr({ to: "wongfoo" }); assert.equal("wongfoo", (_a = elem.getAttribute("to")) === null || _a === void 0 ? void 0 : _a.value()); elem.attr({ to: "julie newmar" }); assert.equal("julie newmar", (_b = elem.getAttribute("to")) === null || _b === void 0 ? void 0 : _b.value()); assert.done(); }; module.exports.attrs = function (assert) { var doc = libxml.Document(); var elem = doc.node("root"); assert.deepEqual([], elem.attrs()); elem.attr({ foo: "bar" }); elem.attr({ bar: "baz" }); elem.attr({ baz: "foo" }); var attrs = [elem.getAttribute("foo"), elem.getAttribute("bar"), elem.getAttribute("baz")]; for (var i = 0; i < 3; ++i) { assert.ok(attrs[i] == elem.attrs()[i]); } assert.done(); }; module.exports.siblings = function (assert) { var _a, _b, _c, _d; var doc = libxml.Document(); var elem = doc.node("root"); elem.attr({ foo: "bar" }); elem.attr({ bar: "baz" }); elem.attr({ baz: "foo" }); assert.equal(elem.getAttribute("baz"), (_a = elem.getAttribute("bar")) === null || _a === void 0 ? void 0 : _a.nextSibling()); assert.equal(elem.getAttribute("foo"), (_b = elem.getAttribute("bar")) === null || _b === void 0 ? void 0 : _b.prevSibling()); assert.equal(null, (_c = elem.getAttribute("foo")) === null || _c === void 0 ? void 0 : _c.prevSibling()); assert.equal(null, (_d = elem.getAttribute("baz")) === null || _d === void 0 ? void 0 : _d.nextSibling()); assert.done(); }; module.exports.getters = function (assert) { var _a, _b; var doc = libxml.Document(); var elem = doc.node("root"); elem.attr({ foo: "bar" }); assert.equal(elem, (_a = elem.getAttribute("foo")) === null || _a === void 0 ? void 0 : _a.parent()); assert.equal(doc, (_b = elem.getAttribute("foo")) === null || _b === void 0 ? void 0 : _b.doc()); assert.done(); }; //# sourceMappingURL=node_attributes.js.map