can't read Element.prototype in firefox

后端 未结 3 1885
死守一世寂寞
死守一世寂寞 2021-01-03 09:14

If I run this javascript:

var a,b=Element.prototype;
for(a in b)b[a];

Firefox gives me this error:

TypeError: Value does no         


        
3条回答
  •  庸人自扰
    2021-01-03 10:06

    The Firefox (and recent IE) behavior here is because the property getters for some properties (say firstChild) are on the prototype object bu the properties make no sense on the prototype itself. Trying to get them on the prototype will throw.

    This is the behavior required by the specification, in fact. See http://dev.w3.org/2006/webapi/WebIDL/#dfn-attribute-getter step 2 substep 2 subsubstep 2. Firefox and IE are following the spec here and WebKit-based browsers are not.

提交回复
热议问题