MathML Blogs: Firefox issue resolved

Thursday, November 20, 2008

Firefox issue resolved

I did some lookup on getElementsByTagName. I found that it supposed to return a 'livenode' meaning a reference to the list. So, the nodelist returned by getElementsByTagName can grow or shrink. I am surprised that it is live in Firefox 2.0, yet static in Firefox 3.0.

As the nodes in the nodelist are modified and replaced, the nodelist was shrinking in Firefox 2.0, so I made some changes to the convert code as follows and it now works with Firefox 2.0.

function convert() {
var i,j,k;
if (document.createElementNS == null)
return;
var mmlnode = document.getElementsByTagName("m:math");
k = mmlnode.length;
for (i=0; i< k; i++) {
if (mmlnode.length < k)
j= 0;
else j = i;
mmlnode[j].parentNode.replaceChild(convertMath(mmlnode[j]),mmlnode[j]);
}
}

No comments:

Post a Comment