Permalink
Browse files

moving towards using setNamedItemNS instead of setAttribute, as the i…

…nternals need to be different
  • Loading branch information...
1 parent 8ce71ff commit 24d3ce7668baf85800f143e9f0b98719f622c0b6 @tmpvar tmpvar committed Feb 6, 2011
Showing with 8 additions and 18 deletions.
  1. +8 −18 lib/jsdom/level2/core.js
View
@@ -313,7 +313,8 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
{
var s = qualifiedName.split(':'),
local = s.pop(),
- prefix = s.pop() || null;
+ prefix = s.pop() || null,
+ attr;
ns.validate(qualifiedName, namespaceURI);
@@ -331,28 +332,17 @@ core.Element.prototype.setAttributeNS = function(/* string */ namespaceURI,
throw new core.DOMException(core.NAMESPACE_ERR);
}
- var found = this._attributes._map(function(attr) {
- if (namespaceURI === attr.namespaceURI &&
- attr.localName === local)
- {
- return true;
- }
- })[0] || null;
+ attr = this._attributes.getNamedItemNS(namespaceURI, local);
- if (!found) {
+ if (!attr) {
attr = this.setAttribute(qualifiedName, value);
- if (attr) {
- attr.namespaceURI = namespaceURI;
- attr._localName = local;
- attr._prefix = prefix;
- }
- } else {
- found.qualifiedName = qualifiedName;
- found.value = value;
- found._localName = local;
}
+ attr._namespaceURI = namespaceURI;
+ attr._prefix = prefix;
attr._created = true;
+ attr.value = value;
+ attr._localName = local;
return attr;
};

0 comments on commit 24d3ce7

Please sign in to comment.