Permalink
Browse files

small perf improvement (_attributes instead of attributes getter)

  • Loading branch information...
1 parent 6de65cb commit 3dd21e5749e2f556aa0105572c7490c928fc7481 @tmpvar tmpvar committed Feb 6, 2011
Showing with 15 additions and 15 deletions.
  1. +15 −15 lib/jsdom/level2/core.js
@@ -154,11 +154,11 @@ core.NamedNodeMap.prototype.getNamedItemNS = function(/* string */ namespaceURI,
return this._map(function(item) {
var node = null, equal = item.localName === localName;
- if (item.ownerDocument &&
- item.ownerDocument.doctype &&
- item.ownerDocument.doctype.attributes)
+ if (item._ownerDocument &&
+ item._ownerDocument.doctype &&
+ item._ownerDocument.doctype._attributes)
{
- node = this._ownerDocument.doctype._attributes.getNamedItem(localName);
+ node = item._ownerDocument.doctype._attributes.getNamedItem(localName);
}
if (namespaceURI === item.namespaceURI || !namespaceURI) {
@@ -245,7 +245,7 @@ core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceUR
this.removeNamedItem(found.name);
if (defaultEl) {
- defaultAttr = defaultEl.attributes.getNamedItemNS(namespaceURI, localName);
+ defaultAttr = defaultEl._attributes.getNamedItemNS(namespaceURI, localName);
if (defaultAttr) {
clone = defaultAttr.cloneNode(true);
@@ -331,7 +331,7 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
attr = this.ownerDocument.createAttributeNS(namespaceURI,
qualifiedName,
value);
- this.attributes.setNamedItemNS(attr);
+ this._attributes.setNamedItemNS(attr);
attr._ownerElement = this;
}
@@ -359,11 +359,11 @@ core.Element.prototype.removeAttributeNS = function(/* string */ namespaceURI,
clone;
if (defaultEl) {
- defaultAttr = defaultEl.attributes.getNamedItemNS(namespaceURI, localName);
+ defaultAttr = defaultEl._attributes.getNamedItemNS(namespaceURI, localName);
}
if (found) {
- this.attributes.removeNamedItemNS(namespaceURI, localName);
+ this._attributes.removeNamedItemNS(namespaceURI, localName);
}
if (defaultAttr) {
@@ -397,7 +397,7 @@ core.Element.prototype.setAttributeNodeNS = function(/* Attr */ newAttr)
} catch (e) { /* noop */}
newAttr._ownerElement = this;
- this.attributes.setNamedItemNS(newAttr);
+ this._attributes.setNamedItemNS(newAttr);
return existing || null;
};
@@ -431,7 +431,7 @@ core.Element.prototype.getElementsByTagNameNS = function(/* String */ namespaceU
core.Element.prototype.hasAttribute = function(/* string */name)
{
- if (!this.attributes) {
+ if (!this._attributes) {
return false;
}
return this._attributes.exists(name);
@@ -498,10 +498,10 @@ core.Document.prototype.importNode = function(/* Node */ importedNode,
if (el.id) {
self._ids[el.id] = el;
}
- if (el.attributes) {
- el.attributes._ownerDocument = self;
- for (var i=0,len=el.attributes.length; i < len; i++) {
- attr = el.attributes.item(i);
+ if (el._attributes) {
+ el._attributes._ownerDocument = self;
+ for (var i=0,len=el._attributes.length; i < len; i++) {
+ attr = el._attributes.item(i);
attr._ownerDocument = self;
attr._specified = true;
}
@@ -513,7 +513,7 @@ core.Document.prototype.importNode = function(/* Node */ importedNode,
// TODO: This could use some love
if (defaultEl) {
- defaultEl.attributes._map(function(defaultAttr) {
+ defaultEl._attributes._map(function(defaultAttr) {
if (!el.hasAttributeNS(defaultAttr.namespaceURL,
defaultAttr.localName))
{

0 comments on commit 3dd21e5

Please sign in to comment.