ncubeait
22 Dec 2006, 4:31 PM
Hi Jack,
Great work on the library!.
I believe I found a bug in the IE table hack work-around. Basically, "firstChild" was being called one too many times on tempTableEl. Here is the patched function:
var insertIntoTable = function(tag, where, el, html){
if(!tempTableEl){
tempTableEl = document.createElement('div');
}
var node;
if(tag == 'table' || tag == 'tbody'){
tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>';
node = tempTableEl.firstChild.firstChild;
}else{
tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>';
node = tempTableEl.firstChild.firstChild.firstChild;
}
if(where == 'beforebegin'){
el.parentNode.insertBefore(node, el);
return node;
}else if(where == 'afterbegin'){
el.insertBefore(node, el.firstChild);
return node;
}else if(where == 'beforeend'){
el.appendChild(node);
return node;
}else if(where == 'afterend'){
el.parentNode.insertBefore(node, el.nextSibling);
return node;
}
}
Now the only problem with this work-around is that if you then try to dynamically set the innerHTML on one of the moved cells, IE will throw an error.
To try out, simply try to perform the following after moving the node:
node.innerHTML = '123';
If you do, IE will throw an "Unknown runtime error". Any suggestions on how to get around this?
William
Great work on the library!.
I believe I found a bug in the IE table hack work-around. Basically, "firstChild" was being called one too many times on tempTableEl. Here is the patched function:
var insertIntoTable = function(tag, where, el, html){
if(!tempTableEl){
tempTableEl = document.createElement('div');
}
var node;
if(tag == 'table' || tag == 'tbody'){
tempTableEl.innerHTML = '<table><tbody>'+html+'</tbody></table>';
node = tempTableEl.firstChild.firstChild;
}else{
tempTableEl.innerHTML = '<table><tbody><tr>'+html+'</tr></tbody></table>';
node = tempTableEl.firstChild.firstChild.firstChild;
}
if(where == 'beforebegin'){
el.parentNode.insertBefore(node, el);
return node;
}else if(where == 'afterbegin'){
el.insertBefore(node, el.firstChild);
return node;
}else if(where == 'beforeend'){
el.appendChild(node);
return node;
}else if(where == 'afterend'){
el.parentNode.insertBefore(node, el.nextSibling);
return node;
}
}
Now the only problem with this work-around is that if you then try to dynamically set the innerHTML on one of the moved cells, IE will throw an error.
To try out, simply try to perform the following after moving the node:
node.innerHTML = '123';
If you do, IE will throw an "Unknown runtime error". Any suggestions on how to get around this?
William