Skip to content

Commit

Permalink
Apply namespaces to attributes immediately.
Browse files Browse the repository at this point in the history
Namespace declarations take effect immediately in XML affecting the
current element and attributes. The current implementation did not
appear to apply namespaces to the attributes belonging to the same
element in which the namespace was declared.

Upon inspecting the code, the loop that is supposed to perform this
assignment does not actually loop through the attribute array. It
increments a index, but it does update the local variable used to
reference the attribute in the attribute list at the index.

With this commit, the local variable is updated. A test has been added
to the DOM attributes test suite to ensure that namespaces are applied
to attributes immediately.
  • Loading branch information
flatheadmill committed Jun 18, 2012
1 parent 063add7 commit dc0ecd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions sax.js
Expand Up @@ -278,6 +278,7 @@ function appendElement(contentHandler,elStack,el,tagName,selfClosed){
}
var i = el.length;
while(i--){
a = el[i];
var prefix = a.prefix;
if(prefix){//no prefix attribute has no namespace
if(prefix === 'xml'){
Expand Down
4 changes: 4 additions & 0 deletions test/dom/attr.js
Expand Up @@ -31,6 +31,10 @@ wows.describe('XML attrs').addBatch({
// root.firstChild.setAttributeNode(root.attributes[0]);
// console.assert(root.attributes.length == 0);
},
"attribute namespace":function(){
var root = new DOMParser().parseFromString("<xml xmlns:a='a' xmlns:b='b' a:b='e'></xml>",'text/xml').documentElement;
console.assert(root.getAttributeNS("a", "b"), "e");
},
"override ns attribute":function(){

},
Expand Down

0 comments on commit dc0ecd7

Please sign in to comment.