-
Notifications
You must be signed in to change notification settings - Fork 139
Why do we believe making mayCancel false as a default is at all backward-compatible? #22
Comments
I don't think this is anyone's intention. I guess you're saying that if the third argument is missing, it should be treated like the default dictionary values Ways around this:
There's also #21 casting some doubt on whether overloading the third argument will be web compatible. |
Hmm, I hadn't considered 1. It is pretty crazy though. Overall I would prefer 2. |
2 - leads to a double negative which can be confusing to understand. But maybe it is just me... ie; you could call it willNotCancel And then the default is false. |
No, negative argument names are a confusing anti-pattern. We either need to come up with a positive name of the opposite meaning, or leave it as it is, with prose making it clear that the default dictionary value (true) is used by default when the dict isn't passed. |
The fundamental issue here is that we have two notions of "default". One is what we want the behavior to be for developers opting-in to the new API form but not specifying mayCancel explicitly, and one is what we need the behavior to be for code unaware of the new API form. I.e. why do we think the "default" behavior for the existing API should be the same as the "default" behavior for a new API form? I don't think we want to invert the meaning because when the developer has opted into the new API we still want If we consider the |
It is weird to say that addEventListener(s, f) is different than addEventListener(s, f, {}). Very, very weird. |
Idea of sorts... Change:
Once you start using the dictionary the default flips. |
this is bizarre. |
I'm not sure what the motivation here is anyway for making mayCancel false the default. It is to save characters so you can type |
@domenic No, I imagine it's so that you automatically opt into the "better" model if you're using the newer API variant. (Legacy code continues to use the legacy behavior.) Most code isn't trying to cancel anything, and as we add optimizations for non-cancelling events of various types, it's better if most stuff automatically works better. This does mean that, right now, without very many options in the dictionary, there may be code that just does It is weird that (I might call the new option
Agree that making the behavior change based on whether some keys are in the dictionary or not is bizarre and unwanted. You also need to hack around WebIDL by specifying the type as |
Euhm yes it would. You just don't define defaults. Mutation observers does something like this. Where the state of some fields depends on others to make the API more convenient to use. |
This breaks every piece of code in the world that currently does
e.preventDefault()
. Why do we think this is OK?The text was updated successfully, but these errors were encountered: