Re: Faking host objects

On Saturday, 29 December 2012 at 18:12, François REMY wrote:
> You should not try to replicate Chrome too much. My personnal experience told me that Chrome do not respect WebIDL in many occasions.


True. Like I don't know where the Empty() function comes from :)  
  
> For example, the DOMInterface.prototype should be of type “DOMInterfacePrototype” and this is not the case in Chrome; also, most properties that should be ‘getter/setter’ following WebIDL are considered value properties in Chrome, something that’s not logical (a value property does not have a setter so should no throw an error when set, nor perform type conversions).

Also true. And sometimes the properties appear on the instance rather than the prototype.   
>  
>  
> Internet Explorer does a much better job than the other browsers on that matter because they rewrote their binding API entirely for IE9 and followed the WebIDL spec very closely. Here are some examples:
>  
> ({}).toString.call(Node.prototype);
> "[object NodePrototype]"
>  
> Object.getOwnPropertyDescriptor(HTMLElement.prototype, "onclick");
> {
> get : function onclick() { [native code] } ,
> set : function onclick() { [native code] } ,
> enumerable : true,
> configurable : true
> }

Did not know that about IE… have not used IE in about 5-6 years, tbh.   
>  
> BTW, Object.getOwnPropertyDescriptor(Event.prototype,'initEvent').enumerable returns “true” on my computer, so I don’t see exactly why you set enumerable to false. By the way, the WebIDL spec clearly states that properties have [[Enumerable]] set to true if not specified otherwhise: http://dev.w3.org/2006/webapi/WebIDL/#ecmascript-binding

Seems I must have misread the spec. I've fixed that locally.  

Problem I'm still having is I that ( foo instanceof Foo ) is returning false. I've managed to get that to work properly before, but it's eluding me now. Any help would be great.   

Received on Saturday, 29 December 2012 20:02:49 UTC