Skip to content
This repository has been archived by the owner on Mar 19, 2018. It is now read-only.

passive is ambiguous #33

Closed
rik opened this issue Apr 14, 2016 · 14 comments
Closed

passive is ambiguous #33

rik opened this issue Apr 14, 2016 · 14 comments

Comments

@rik
Copy link

rik commented Apr 14, 2016

When first being introduced to this feature, I assumed that passive events where sort of "read-only" events. Meaning they could not change the DOM. After reading a bit more, I realise it only removes the preventDefault method on events.

Because they only do one thing, I'm suggesting to rename the option : preventable. It defaults to true and you set it to false to get the performance benefits.

@annevk
Copy link
Collaborator

annevk commented Apr 14, 2016

We cannot have arguments default to true. That is a bad practice.

@rik
Copy link
Author

rik commented Apr 14, 2016

Why?

@annevk
Copy link
Collaborator

annevk commented Apr 14, 2016

Because you have to learn the defaults otherwise.

@rik
Copy link
Author

rik commented Apr 14, 2016

I'm not sure I understand. We do have to learn the defaults regardless of the meaning of the boolean. I have to learn that by default, event listeners can block scrolling.

@annevk
Copy link
Collaborator

annevk commented Apr 14, 2016

If they all default to false, as they fortunately mostly do, you know whether you can omit the argument when reading code and such and whether it being specified has an effect. I can't really find a canonical reference for this, but this is the way it is. https://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/thread.html#msg302 has some debate on the subject.

@foolip
Copy link
Member

foolip commented Apr 14, 2016

The reason to avoid true as a default that I've found most compelling is that undefined should map to the default, which means that { passive: false } and { passive: undefined } would mean different things even though both are falsy values.

@annevk
Copy link
Collaborator

annevk commented Apr 14, 2016

See w3ctag/design-principles#28 about getting this documented.

@RByers
Copy link
Member

RByers commented Apr 14, 2016

And pragmatically we've already bike-shedded this name to death over the path many months (eg. #13, #14, #17). Since this is now shipping in Chrome and is being actively adopted by websites, we'd need a strong justification to change the name at this point.

@RByers RByers closed this as completed Apr 14, 2016
@rik
Copy link
Author

rik commented Apr 15, 2016

Thanks for the boolean defaults pointers, it's very helpful.

@rik
Copy link
Author

rik commented Apr 15, 2016

I don't think it is too late to change the name. One browser does not make a standard. Also, since it's a dictionary, it's easy for websites to add another property.

In previous bike-sheds, did you receive feedback from web authors? I only see regular web standards participants in the conversations you linked.

My preference is disableCancel, like @domenic. This change is beneficial for web authors outside of the performance benefits because it gives them a guarantee that no one (aka another person working on the same website in the future) will accidentally preventDefault that event.

@annevk
Copy link
Collaborator

annevk commented Apr 15, 2016

No it doesn't. Another person could set up their own listener. The only guarantee is that the listener is passive, that's it.

@rik
Copy link
Author

rik commented Apr 15, 2016

Yeah sorry, I got my terminology wrong here. But my point still stands.

@annevk
Copy link
Collaborator

annevk commented Apr 15, 2016

I don't really see how it does.

@tabatkins
Copy link
Collaborator

disableCancel

Another boolean design practice is to always name your booleans with a positive attribute, not a negative one. Negating a negative attribute makes things harder to understand. (Follow the link above to http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html and read the "double negative" section.)

I don't think it is too late to change the name. One browser does not make a standard.

No, but gratuitous changes still shouldn't be taken lightly. It invalidates previous information spread around, and requires additional work by the implementors that have already done some work, and early-adopter authors.

It's not difficult to change names, but it's not trivial either. The new name needs to be a significant improvement (like passive was over the previous names).

Also, since it's a dictionary, it's easy for websites to add another property.

What's not easy is updating anything - as a first approximation, websites are never updated.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants