UNPKG

ajsfw

Version:
156 lines (155 loc) 5.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var NodeListOf_1 = require("./NodeListOf"); var Node = (function () { function Node(nodeType, nodeName, ownerDocument) { this.__parentNode = null; this.__nodeType = nodeType; this.__nodeName = nodeName; this.__ownerDocument = ownerDocument; this.__childNodes = new NodeListOf_1.default(this); this._nodeValue = null; this.nextSibling = null; this.previousSibling = null; } Object.defineProperty(Node.prototype, "ownerDocument", { get: function () { return this.__ownerDocument; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "nodeType", { get: function () { return this.__nodeType; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "nodeName", { get: function () { return this.__nodeName; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "parentNode", { get: function () { return this.__parentNode; }, set: function (node) { this.__parentNode = node; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "parentElement", { get: function () { if (this.__parentNode.nodeType !== Node.ELEMENT_NODE) { return null; } return this.__parentNode; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "nodeValue", { get: function () { if (this.__nodeType !== Node.TEXT_NODE && this.__nodeType !== Node.COMMENT_NODE) { return null; } return this._nodeValue; }, set: function (value) { if (this.__nodeType !== Node.TEXT_NODE && this.__nodeType !== Node.COMMENT_NODE) { return; } this._nodeValue = value; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "textContent", { get: function () { if (this.__nodeType === Node.DOCUMENT_NODE) { return null; } var value = this.nodeValue || ""; var node = this.__childNodes.firstNode; while (node !== null) { value += node.textContent || ""; node = node.nextSibling; } return value; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "innerText", { get: function () { if (this.__nodeType === Node.COMMENT_NODE) { return null; } var value = this.nodeValue || ""; var node = this.__childNodes.firstNode; while (node !== null) { value += node.innerText || ""; node = node.nextSibling; } return value; }, enumerable: true, configurable: true }); Node.prototype.hasChildNodes = function () { return this.__childNodes.length > 0; }; Node.prototype.contains = function (node) { return this.__childNodes.itemIndex(node) !== -1; }; Object.defineProperty(Node.prototype, "childNodes", { get: function () { return this.__childNodes; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "firstChild", { get: function () { return this.__childNodes.firstNode; }, enumerable: true, configurable: true }); Object.defineProperty(Node.prototype, "lastChild", { get: function () { return this.__childNodes.lastNode; }, enumerable: true, configurable: true }); Node.prototype.appendChild = function (node) { this.__childNodes.append(node); node.parentNode = this; return node; }; Node.prototype.insertBefore = function (newNode, beforeNode) { this.__childNodes.insertBefore(newNode, beforeNode); newNode.parentNode = this; return newNode; }; Node.prototype.replaceChild = function (newNode, oldNode) { this.__childNodes.replaceNode(newNode, oldNode); newNode.parentNode = this; return newNode; }; Node.prototype.removeChild = function (node) { this.__childNodes.removeNode(node); }; return Node; }()); Node.ELEMENT_NODE = 1; Node.TEXT_NODE = 3; Node.COMMENT_NODE = 8; Node.DOCUMENT_NODE = 9; exports.default = Node;