On WebKit nightly and the latest version of Chrome, the following shows two alerts. On Firefox, it shows one alert. Which is correct? NOTE 1 in 15.2.4.5 Object.prototype.hasOwnProperty of the ECMAScript Language Spec says: "this method does not consider objects in the prototype chain", I couldn't figure out if that's relevant. ECMAScript Language Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf ---- <p id="element">Sample Text</p> <SCRIPT type="text/javascript"> var o = document.getElementById("element"); if(o.hasOwnProperty('style')) { alert(o.nodeName + ' has \'style\' as the direct property of the object.'); } if('style' in o) { alert(o.nodeName + ' has \'style\' as a property in the object\'s prototype chain.'); } </SCRIPT>
I believe this is actually a WebIDL related bug, and that Firefox's behavior is correct. I believe hasOwnProperty is working correctly on both browsers, and that it is actually the DOM that is different (in Safari, 'style' is a property of the element, in Firefox it is presumably a property of the prototype). If so, it is Firefox behaving correctly – I believe WebIDL specifies that such properties should be on the prototype.
> property of the element, in Firefox it is presumably a property of the prototype Which is a of course a general issue that has been reported before. Not sure what the best original is.
*** This bug has been marked as a duplicate of bug 49739 ***