HasOwnProperty HTMLElement Firefox

Friends,

I noticed in Firefox v23.0.1 that hasOwnProperty HTMLElement (input, button..etc) does not work,

 button1.hasOwnProperty('id') = false 

I use to check:

  var str1 = ''; for (pp in button1) { if (button1.hasOwnProperty(pp)) { str1 += (',' + pp); } } alert(str1);//nothing here 

but in chrome hasOwnProperty works well.

Do you know that this is a mistake?

+6
source share
1 answer

Per spec, the id property is either on HTMLElement.prototype or on Element.prototype (depending on the specification version).

Firefox is right. Chrome puts all properties directly on objects.


http://dev.w3.org/2006/webapi/WebIDL/#es-attributes http://dev.w3.org/2006/webapi/WebIDL/#ecmascript-binding
+5
source

Source: https://habr.com/ru/post/952632/


All Articles