javascript - How come there is a difference between Chrome and Firefox here? -


I am using a recursive function based around (for .. ..) and cloning objects For hasOwnProperty, which works properly IE and FF ... but not Chrome.

If the object is a DOM object, then going to the members of the object for Firefox and Chrome (... in ...), different results have been given for OvenProperty.

  var t = document.createElement ("table");  

In the firebugs (FF) console displays versus Chrome console: Var tr = t.insertRow (-1); For (tr in var p) if (tr.hasOwnProperty (p)) console.log (p);

Firefox output:

Producer - addEventListener

Chrome output:

ClientLeft
scrollHeight
FirstAntentBill
OffsetPart
CIFs Offsetwidth
Icantent Edit / Hidden
Element Cylling
Parent Element
Local Name
Children / Owner
Document
Nodewella
Ultimate Element Child
Line Index
Offset Late
Tagname
ClassName
Prefix
Inner HTML
Previous She Ings
Namesphere IRI
ID
Child AlimentCount
Init Text - Scroll Left
Client Height
Align
Text Content
Next Sibling
Scroll- Wide
OffsetHight
Chauf
ClientWuth
Nodnames
Style
Long
Scroll Hat
Offsettop
Ballaindas
Basuri - Next Element Sibling
VAlign
sectionRowindex
classList
title
firstChild
attributes
dataset
external text
cells
parenting Oud
clienttop
tabindx
contentEditable
External HTML





bgColor
nodetype
SpellCheck - Dragable

HowonProperty All the additional properties flagged as correct for my code are 'sufficient to infinite / crash'. Is there a way to determine whether a property is built in the dom object property? Or some other solution ..

Its easiest way is to check the method and use it Is it if it exists.

This means that your cloning method will check any domain nodes and use the preset DOM method on it. It should completely avoid your problem.

For your real problem, it appears that Chrome and Firefox disagree on the object for prototype and HTMLToLoilment (and also as any other element).

Compare console.dir (HTMLTableRowElement) in both Firefox and Chrome.

All of these properties in Firefox remain on the HTMLTableRowElement prototype. Where chrome prototype has only a few modes ( delecteCell and insertCell ).

No, where it says in the DOM specification whether HTMLElements should be defined on the propertys prototype or the object, especially something similar that you should not trust.

Use .cloneNode in any way, because it is an original method and hence is better / faster then 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 pretend implementation

  function HTMLTableRowElement () {...} HTMLTableRowElement.prototype.nextSibling = ...; HTMLTableRowElement.prototype.nodeName = ...; HTMLTableRowElement.prototype.nodeType = ...; ... HTMLTableRowElement.prototype.deleteCell = function () {...}; HTMLTableRowElement.prototype.insertCell = function () {...};    

Comments