-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is overriding protection for .off appropriate? #17844
Comments
What would the motivation for forbidding overriding be? |
Copying comment by @ChALkeR in this comment: Everyone, do you think if an attempt to override it should warn users? Such overriding would mean one of two things:
See the rest of the discussion there. Pinging people who weighed in @ChALkeR @ljharb @BridgeAR |
I think a simple warning when .off is overridden with anything besides removeEventListener (the current value) should suffice. When it’s overridden with the correct value, i think it’s fine and no warning is needed. |
@benjamingr It isn’t quite clear from that comment, but I think that means what you are talking about is |
My interpretation was about monkeypatching the prototype; it’s perfectly fine for someone to do anything they like to the instance. |
It’s weird, but my thinking would be reversed I guess? Maybe there’s something special about Since the API here is well-defined, it should be safe for userland to override it as long as they know they are overriding it, right? I can see how people might be surprised to find out that |
Shadowing a prototype method on an instance only risks surprising/breaking the tiny segment of code that interacts with it, which will likely be located nearby. Monkeypatching a prototype affects all code in the entire process. |
I’m okay with making |
This includes three npm releases, one of which is pretty big (5.4.0). Changes of Note * Significant performance boost for installations from cache (~10%+) * A number of bugfixes for important and severe bugs affecting installation on all supported platforms, but particularly noticeable on Windows. * More Windows-related fixes for `npx`. * [nodejs#17844](npm/npm#17844) Make package-lock.json sorting locale-agnostic. This will cause some users to see seemingly spurious diffs on their pkglocks if they were using previous versions of npm5, because, for example, `JSONStream` is sorted into a different location. This is fine and will go away as people upgrade. Changelogs * [`v5.4.0`](https://github.com/npm/npm/releases/tag/v5.4.0) * [`v5.4.1`](https://github.com/npm/npm/releases/tag/v5.4.1) * [`v5.4.2`](https://github.com/npm/npm/releases/tag/v5.4.2)
I'm -1 in adding override protection or emitting a warning. I think it's good as it is. |
What is the conclusion here? Can this issue be closed? |
Hey, Follow up on #17156 ,
Do you think a PR on the matter of overriding protection for .off is appropriate, and if so, what scenarios should be regarded?
The text was updated successfully, but these errors were encountered: