Sha256: f7abd237431765b22380ba529af8eabd05db2bba5dca1a22b2b66c4e80fa095b

Contents?: true

Size: 915 Bytes

Versions: 45

Compression:

Stored size: 915 Bytes

Contents

// This object will be used as the prototype for Nodes when creating a
// DOM-Level-1-compliant structure.
var NodePrototype = module.exports = {
	get firstChild() {
		var children = this.children;
		return children && children[0] || null;
	},
	get lastChild() {
		var children = this.children;
		return children && children[children.length - 1] || null;
	},
	get nodeType() {
		return nodeTypes[this.type] || nodeTypes.element;
	}
};

var domLvl1 = {
	tagName: "name",
	childNodes: "children",
	parentNode: "parent",
	previousSibling: "prev",
	nextSibling: "next",
	nodeValue: "data"
};

var nodeTypes = {
	element: 1,
	text: 3,
	cdata: 4,
	comment: 8
};

Object.keys(domLvl1).forEach(function(key) {
	var shorthand = domLvl1[key];
	Object.defineProperty(NodePrototype, key, {
		get: function() {
			return this[shorthand] || null;
		},
		set: function(val) {
			this[shorthand] = val;
			return val;
		}
	});
});

Version data entries

45 entries across 42 versions & 5 rubygems

Version Path
trusty-cms-6.3.1 node_modules/domhandler/lib/node.js
trusty-cms-5.0.7 node_modules/domhandler/lib/node.js
trusty-cms-5.0.6 node_modules/domhandler/lib/node.js
trusty-cms-5.0.5 node_modules/domhandler/lib/node.js
trusty-cms-5.0.4 node_modules/domhandler/lib/node.js
trusty-cms-5.0.3 node_modules/domhandler/lib/node.js
trusty-cms-5.0.2 node_modules/domhandler/lib/node.js
trusty-cms-5.0.1 node_modules/domhandler/lib/node.js
trusty-cms-4.3.5 node_modules/domhandler/lib/node.js
trusty-cms-5.0.0 node_modules/domhandler/lib/node.js
trusty-cms-4.3.4 node_modules/domhandler/lib/node.js
trusty-cms-4.3.3 node_modules/domhandler/lib/node.js
trusty-cms-4.3.2 node_modules/domhandler/lib/node.js
trusty-cms-4.3.1 node_modules/domhandler/lib/node.js
trusty-cms-4.3 node_modules/domhandler/lib/node.js
trusty-cms-4.2.3 node_modules/domhandler/lib/node.js
trusty-cms-4.2.2 node_modules/domhandler/lib/node.js
trusty-cms-4.2.1 node_modules/domhandler/lib/node.js
trusty-cms-4.2 node_modules/domhandler/lib/node.js
trusty-cms-4.1.9 node_modules/domhandler/lib/node.js