Comments (5)
I have previously said similar things: #17981 but I don't know what people generally feel about changing the syntax conventions.
from content.
Hi, we never add the target for methods, because people often take them as global variables or that you must use an identifier to get them. You can check all other instance methods' syntax. Is this particularly confusing for event listeners?
from content.
Oh, I never noticed that! Glad it's consistent at least :D
I can see your point, but I'd think that omitting the target is just as confusing. Other arguments that are passed to the method call in the syntax examples are written using identifiers (e.g. readAsArrayBuffer(blob)
) or literal expressions (e.g. .addEventListener("load", (event) => {})
) as well, does this cause people to assume that blob
is a global variable or that the event handler must be an arrow function?
I think that by omitting the target, the chances increase the people mistake the method for a global function. Which might not even throw an error if there's a method of the same name on window
.
And yes, I think this syntax is particularly confusing for setter properties like onload
.
If you don't want to use an identifier, how about including at least the dot
.addEventListener("load", (event) => {});
.onload = (event) => {};
or even an ellipsis?
….addEventListener("load", (event) => {});
….onload = (event) => {};
from content.
The current format of the "Syntax" box was decided on in #2202, as part of openwebdocs/project#26. If we wanted to revisit it, it would be better to open a discussion than an issue: that said I don't know if there's much appetite for reanimating this conversation now.
from content.
@wbamberg thanks for the link! From what I read in #2202 that discussion was about converting bnf syntax for optional parameters to multiline syntax examples, not about dropping the target object.
Anyhow, @Josh-Cena already did open https://github.com/orgs/mdn/discussions/148 so I'll chime in there
from content.
Related Issues (20)
- terms "this", "target", "recipient", "window", "origin" appear indistinctly used HOT 2
- i dont understand but victim still
- The example code generates DomException using Firefox and is blocked in Chrome and Edge
- Example code has the condition reversed
- CSS reference gives instructions that might be considered incomplete for the display: none property
- Typo in HTTP Cookies, "Updating cookies via JavaScript" Section HOT 4
- Typo error in If-Modified-Since page makes content seem seem wrong and/or confusing HOT 4
- Service Workers are no longer a requirement for PWA installation HOT 1
- Animation does not work for cube and torus HOT 2
- MIME type for JPG is not image/jpeg, it is image/jpg HOT 2
- Small typo HOT 1
- Native messaging example with python 3.12.4 does not work HOT 1
- Updating `sessionStorage` is not firing storage event. Only updating `localStorage` fires the storage event. HOT 2
- Webauthn latest specs HOT 3
- WebGPU is in Safari TP
- Number.prototype.toString() on numbers that CAN be represented in float64 but not exactly in toString() HOT 2
- Document CloseWatcher API
- Document Storage Buckets API
- Numeric Range Syntax not mentioned
- Express - Unexpected token error after following instructions? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from content.