- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Mon, 9 Jun 2014 13:22:03 -0700
- To: Travis Leithead <travis.leithead@microsoft.com>
- Cc: Gary Kačmarčík (Кошмарчик) <garykac@google.com>, "Anne van Kesteren (annevk@annevk.nl)" <annevk@annevk.nl>, "Boris Zbarsky (bzbarsky@mozilla.com)" <bzbarsky@mozilla.com>, Cameron McCormack <cmccormack@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Mon, Jun 9, 2014 at 1:07 PM, Travis Leithead <travis.leithead@microsoft.com> wrote: > Hey folks, > > I was reviewing a site-compatibility issue with IE on the phone, and ran > across what I think to be a Chrome implementation bug, but I wanted to post > my findings in case I messed up the interpretation—it has to do with > undefined handling in WebIDL I think. > > The API is removeEventListener defined in DOM4 [1] as: > > void removeEventListener(DOMString type, EventListener? callback, optional > boolean capture = false); > > The site-compatibility problem occurs because the site is [unknowingly?] > calling this API with only one param: > > ob.removeEventListener(‘click’); > > and no exception is thrown. In IE and Firefox, this throws because 2 params > are expected to this function. In Chrome, the call silently fails (no > exception). Note that IE and Firefox do not throw when passing undefined > explicitly: ob.removeEventListener(‘click’, undefined). > > Per WebIDL AFAICT, this method would be invoked with the following values: > (‘click’, <missing>, false), since the optional 3rd arg with a default gets > substituted when no value is passed (and would also be substituted if > undefined as a value were specifically passed). I’m pretty sure the nullable > 2nd arg is not considered “optional” per the “optionality” determination in > WebIDL. If it is, then undefined would type-convert to null, and Chrome’s > behavior of not-throwing is right, but I can’t quite see how that would > work. > > Would love your clarification. Is this a Chrome bug or a spec bug? > > [1] http://w3c.github.io/dom/#eventtarget Chrome bug. We've got a lot of places where we use standard JS behavior for missing values (passing in undefined) rather than WebIDL behavior (throwing). ~TJ
Received on Monday, 9 June 2014 20:22:50 UTC