Make qName, localName, and tagName getters/setters

This commit is contained in:
Patrick Steele-Idem 2014-06-04 21:52:59 -06:00
parent 499a8c9259
commit 39b3557c83

View File

@ -41,13 +41,7 @@ function ElementNode(localName, namespace, prefix) {
this.dynamicAttributesExpressionArray = null; this.dynamicAttributesExpressionArray = null;
this.attributesByNS = {}; this.attributesByNS = {};
this.prefix = prefix; this.prefix = prefix;
this.localName = this.tagName = localName; this.localName = localName;
if (this.prefix) {
this.qName = this.prefix + ':' + localName;
} else {
this.qName = localName;
}
this.namespace = namespace; this.namespace = namespace;
this.allowSelfClosing = false; this.allowSelfClosing = false;
this.startTagOnly = false; this.startTagOnly = false;
@ -298,4 +292,33 @@ ElementNode.prototype = {
} }
}; };
require('raptor-util').inherit(ElementNode, require('./Node')); require('raptor-util').inherit(ElementNode, require('./Node'));
Object.defineProperty(ElementNode.prototype, 'tagName', {
get: function() {
return this._localName;
},
set: function(value) {
this._localName = value;
}
});
Object.defineProperty(ElementNode.prototype, 'localName', {
get: function() {
return this._localName;
},
set: function(value) {
this._localName = value;
}
});
Object.defineProperty(ElementNode.prototype, 'qName', {
get: function() {
if (this.prefix) {
return this.prefix + ':' + this.localName;
} else {
return this.localName;
}
}
});
module.exports = ElementNode; module.exports = ElementNode;