- From: Garrett Smith <dhtmlkitchen@gmail.com>
- Date: Wed, 16 Jan 2013 13:14:07 -0800
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: public-script-coord@w3.org, es-discuss <es-discuss@mozilla.org>
On 1/16/13, Boris Zbarsky <bzbarsky@mit.edu> wrote: > On 12/31/12 11:33 PM, Boris Zbarsky wrote: >> 1) Hack instanceof as Gecko has in the past. This is actually a bit of >> a pain to implement even in Gecko, without changes to SpiderMonkey, >> because function objects can't have the magic behavior the RHS needs >> above in SpiderMonkey at the moment. > > We have decided to go this route in Gecko, I believe, given that Allen > says this will be describable in ES6. > > In the short term that means that our WebIDL interface objects will > probably not be function objects but reasonable facsimiles. In the > longer term we'll probably add a way to have functions have custom > instanceof behavior to SpiderMonkey. > I understand the idea of making instanceof less wacky apnd hacky. Is there room for a non-normative warning"don't do that" warning in the spec? Because otherwise, it'll be on stackoverflow and blogs as: Q: How do I know if my object is an element? A: Use instanceof if (x instanceof Element) Where instanceof instanceof might seem generally more reliable. I think it's a good idea to put a warning somewhere (WebIDL?) about compatibility problems and API versions, such as: Using instanceof to determine Object type is not strongly reliable across APIs, API versions, browser manufacturer discrepencies, and browser versions. Authors are encouraged to make more closely related and descriptive checks, such as: // See https://developer.mozilla.org/en-US/docs/DOM/HTMLCanvasElement var isCanvasToBlobSupported = typeof x.toBlob == "function"; -- Garrett Twitter: @xkit personx.tumblr.com
Received on Wednesday, 16 January 2013 21:14:34 UTC