Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hasOwnProperty HTMLElement Firefox

Friends,

I notice in Firefox v23.0.1 that, hasOwnProperty of HTMLElement(input,button..etc) doesn't work,

button1.hasOwnProperty('id') = false

I use for in 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 is it a bug?

like image 354
Lindy Avatar asked Aug 28 '13 03:08

Lindy


1 Answers

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

Firefox gets this right. Chrome puts all properties directly on objects instead.


http://dev.w3.org/2006/webapi/WebIDL/#es-attributes http://dev.w3.org/2006/webapi/WebIDL/#ecmascript-binding
like image 151
Boris Zbarsky Avatar answered Oct 21 '22 04:10

Boris Zbarsky