-
Notifications
You must be signed in to change notification settings - Fork 23k
Update warnings about event handler attributes #42347
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
base: main
Are you sure you want to change the base?
Conversation
Added the implicit `with` statement wrapping that event handler attributes do, and the issues that come with it
| > [!WARNING] | ||
| > While not visible by calling the `Function.prototype.toString()` method on the handler, event handler attributes will implicitly wrap code inside of 2 `with` statements, and may produce unexpected results. For example: | ||
| > ```html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
| > ```html | |
| > | |
| > ```html |
| > ```html | ||
| > <div onclick="console.log(new URL(location))">Bad Example</div> | ||
| > ``` | ||
| > Essentially becomes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
| > Essentially becomes: | |
| > | |
| > Essentially becomes: |
| > <div onclick="console.log(new URL(location))">Bad Example</div> | ||
| > ``` | ||
| > Essentially becomes: | ||
| > ```js example-bad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
| > ```js example-bad | |
| > | |
| > ```js example-bad |
| > with(this.ownerDocument) { | ||
| > with(this) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mdn-linter] reported by reviewdog 🐶
| > with(this.ownerDocument) { | |
| > with(this) { | |
| > with (this.ownerDocument) { | |
| > with (this) { |
|
Preview URLs Flaws (36)URL:
|
Added the implicit
withstatement wrapping that event handler attributes do, and the issues that come with itDescription
Mentioned a (lesser known?) feature of event handler attributes
Motivation
Additional details
Related issues and pull requests