I see what you mean. It was much easier to implement getElementsByTagNameNS() in JavaScript. Here's a diff of the changes that I put together last night for you to review.
--- dom.js 2010-09-22 00:24:26.000000000 +0400
+++ /usr/lib/v8cgi/dom.js 2010-09-22 20:46:28.000000000 +0400
@@ -297,6 +297,31 @@
this.attributes.splice(index, 1);
}
+Element.prototype.getElementsByTagNameNS = function(namespace, tagname) {
+ var result = [], i=0, len=this.childNodes.length;
+
+ for (;i<len;i++) {
+ var child = this.childNodes[i];
+ if (child.nodeType != Node.ELEMENT_NODE) {
+ continue;
+ }
+
+ if ('*' === namespace && '*' === tagname
+ || '*' === tagname && child.nodeName.match(namespace)
+ || '*' === namespace && child.nodeName.match(tagname)
+ || child.nodeName === namespace + ':' + tagname) {
+ result.push(child);
+ }
+
+ var sub = child.getElementsByTagNameNS(namespace, tagname);
+
+ for (var j=0;j<sub.length;j++) {
+ result.push(sub[j]);
+ }
+ }
+ return result;
+}
+
Element.prototype.getElementsByTagName = function(name) {
var result = [];
for (var i=0;i<this.childNodes.length;i++) {
@@ -509,6 +534,7 @@
}
Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
+Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
Document.prototype.cloneNode = function(deep) {
var elm = new Document();