The easiest solution for this is to check the .cloneNode method and use it if it exists.
This means that your cloning method will check for any DOM nodes and use the predefined DOM method on it. This should completely eliminate your problem.
Regarding your real problem. It seems that Chrome and Firefox do not agree with what belongs to the prototype and what belongs to the object for HTMLTableRowElement (and any other element as well).
Compare console.dir(HTMLTableRowElement) with both firefox and chrome.
In firefox, all of these properties are in the HTMLTableRowElement prototype. Where as a chrome prototype there are only a few methods. ( delecteCell and insertCell ).
No, if the DOM specification states whether the HTMLElements properties should be defined on the prototype or on the object, so you should not rely on this.
In any case, use .cloneNode because it is a proprietary method and therefore better / faster than anything you can write in JavaScript.
Chrome psuedo implementation:
function HTMLTableRowElement() { ... this.nextSibling = ...; this.nodeName = ...; this.nodeType = ...; ... } HTMLTableRowElement.prototype.deleteCell = function() { ... }; HTMLTableRowElement.prototype.insertCell = function() { ... };
Firefox Pseudo Implementation
function HTMLTableRowElement() { ... } HTMLTableRowElement.prototype.nextSibling = ...; HTMLTableRowElement.prototype.nodeName = ...; HTMLTableRowElement.prototype.nodeType = ...; ... HTMLTableRowElement.prototype.deleteCell = function() { ... }; HTMLTableRowElement.prototype.insertCell = function() { ... };
source share