Permalink
Browse files

Having a doctype is not a requirement for removing namespaced attributes

  • Loading branch information...
1 parent ffec2c9 commit 1b72347e9bedef96471b8356e9c46b1a34ca2cee @rubys rubys committed Feb 8, 2011
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/jsdom/level2/core.js
View
@@ -243,7 +243,7 @@ core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceUR
var parent = this._parentNode,
found = null,
- defaults = parent.ownerDocument.doctype._attributes,
+ defaults,
clone,
defaultEl,
defaultAttr;
@@ -254,7 +254,6 @@ core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceUR
{
throw new core.DOMException(core.NO_MODIFICATION_ALLOWED_ERR);
}
- defaultEl = defaults.getNamedItemNS(parent._namespaceURI, parent._localName);
if (this._nsStore[namespaceURI] &&
this._nsStore[namespaceURI][localName])
@@ -268,6 +267,11 @@ core.NamedNodeMap.prototype.removeNamedItemNS = function(/*string */ namespaceUR
throw new core.DOMException(core.NOT_FOUND_ERR);
}
+ if (parent.ownerDocument.doctype && parent.ownerDocument.doctype._attributes) {
+ defaults = parent.ownerDocument.doctype._attributes;
+ defaultEl = defaults.getNamedItemNS(parent._namespaceURI, parent._localName);
+ }
+
if (defaultEl) {
defaultAttr = defaultEl._attributes.getNamedItemNS(namespaceURI, localName);
@@ -376,13 +380,18 @@ core.Element.prototype.removeAttributeNS = function(/* string */ namespaceURI,
throw new core.DOMException(core.NO_MODIFICATION_ALLOWED_ERR);
}
- var defaults = this.ownerDocument.doctype._attributes,
+ var defaults,
clone,
found,
- defaultEl = defaults.getNamedItemNS(namespaceURI, this.localName),
+ defaultEl,
defaultAttr,
clone;
+ if (parent.ownerDocument.doctype && parent.ownerDocument.doctype._attributes) {
+ defaults = this.ownerDocument.doctype._attributes;
+ defaultEl = defaults.getNamedItemNS(namespaceURI, this.localName);
+ }
+
if (defaultEl) {
defaultAttr = defaultEl.getAttributeNodeNS(namespaceURI, localName);
}

0 comments on commit 1b72347

Please sign in to comment.