Skip to content

Commit

Permalink
Having a doctype is not a requirement for removing namespaced attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Feb 8, 2011
1 parent ffec2c9 commit 1b72347
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/jsdom/level2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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])
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 1b72347

Please sign in to comment.