hasOwnProperty HTMLElement Firefox

974 Views Asked by At

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?

1

There are 1 best solutions below

11
On

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