Skip to content

Commit

Permalink
Sort attributes for printing
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Jan 16, 2011
1 parent 46b23ce commit f16ac9b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib.js/testrunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ function printTree(node, indent) {
(node.prefix||'') + ', ' + (node.localName||'') + ', ' +
(node.namespaceURI||'') + ')';

names = [];
values = {}
for (var i=0; i<node.attributes.length; i++) {
var attr = node.attributes[i];
tree += '\n| ' + indent + attr.name + '="' + attr.value + '" (' +
names.push(node.attributes[i].name);
values[node.attributes[i].name] = node.attributes[i];
}
names = names.sort();

for (var i=0; i<names.length; i++) {
var attr = values[names[i]];
tree += '\n| ' + indent + names[i] + '="' + attr.value + '" (' +
(attr.prefix||'') + ', ' + (attr.localName||'') + ', ' +
(attr.namespaceURI||'') + ')';
}
Expand Down

0 comments on commit f16ac9b

Please sign in to comment.