- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Mon, 21 Jul 2014 22:11:09 -0400
- To: David Bruant <bruant.d@gmail.com>, www-dom@w3.org
On 7/21/14, 5:08 PM, David Bruant wrote: > One thing we're sure of is that no existing code today both uses Symbols > and assumes that event.type is a string (because Symbols don't exist), > so we're guaranteed that no code on the web would break by allowing > symbols to be used as event names. That's enough for backward > compatibility, no? Maybe I didn't express my mail very carefully... If on() did not have that regexp bit in it, then calling on() with a Symbol would succeed, because it would just call right on through to addEventListener. But then when the event actually happens some parts of jQuery would fail. So you're correct that no current code would be affected in this case, but new code that passed a symbol to on() would have non-obvious failures. Worse yet, jQuery.event.fix is just called on an event. It doesn't have to be called from jQuery itself. It's public API, as far as I can tell, that's commonly used for things like http://stackoverflow.com/questions/9508377/how-to-create-a-jquery-event-object-out-of-a-native-browser-event-object So anyone using this API who suddenly starts to see events come through with Symbol-valued names would have their code break. > But I don't understand why it comes under consideration about > whether the native API should allow something or not. Just because there's a compat risk. Definitely so for the catch-all event listeners browser extensions can do, and for any code that uses a library in this way and then has something else dropped into the page that uses Symbol-named events. >> And note that some browser extension systems do in fact provide such a >> capability. > They'll need to evolve too, very much like browsers evolve their > devtools to acknowledge the presence of symbol properties on objects. Evolving an API is easy. Evolving extensions that are using it... > Back to your original question I think that backwards-compatibility > cannot be an issue by definition since symbols don't exist yet on the > web. I think we simply disagree on what sorts of breakage are acceptable. -Boris
Received on Tuesday, 22 July 2014 02:11:43 UTC