Skip to content

Commit

Permalink
refactor for attribute NS methods to use nameditem NS methods interna…
Browse files Browse the repository at this point in the history
…lly is complete. now time to fix the internal representation
  • Loading branch information
tmpvar committed Feb 6, 2011
1 parent 2d5265e commit 6de65cb
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/jsdom/level2/core.js
Expand Up @@ -296,14 +296,7 @@ core.NamedNodeMap.prototype._map = function(fn) {
core.Element.prototype.getAttributeNS = function(/* string */ namespaceURI,
/* string */ localName)
{
var attr = this._attributes._map(function(attr) {
if (namespaceURI === attr.namespaceURI &&
attr.localName === localName)
{
return true;
}
})[0];

var attr = this._attributes.getNamedItemNS(namespaceURI, localName);
return (attr) ? attr.nodeValue : '';
};

Expand Down Expand Up @@ -335,7 +328,11 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
attr = this._attributes.getNamedItemNS(namespaceURI, local);

if (!attr) {
attr = this.setAttribute(qualifiedName, value);
attr = this.ownerDocument.createAttributeNS(namespaceURI,
qualifiedName,
value);
this.attributes.setNamedItemNS(attr);
attr._ownerElement = this;
}

attr._namespaceURI = namespaceURI;
Expand Down Expand Up @@ -437,13 +434,13 @@ core.Element.prototype.hasAttribute = function(/* string */name)
if (!this.attributes) {
return false;
}
return this.attributes.exists(name);
return this._attributes.exists(name);
};

core.Element.prototype.hasAttributeNS = function(/* string */namespaceURI,
/* string */localName)
{
return !!this.getAttributeNodeNS(namespaceURI, localName);
return !!this._attributes.getNamedItemNS(namespaceURI, localName);
};

core.DocumentType.prototype.__defineGetter__("publicId", function() {
Expand Down

0 comments on commit 6de65cb

Please sign in to comment.