Add warning against using element IDs as global properties.#39422
Merged
Add warning against using element IDs as global properties.#39422
Conversation
…end best practices.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Contributor
|
Preview URLs
(comment last updated: 2025-05-12 01:01:08) |
Josh-Cena
reviewed
May 7, 2025
Comment on lines
+54
to
+63
| > For example, if we had an element with an `id="performance"`, the following code would've worked before the introduction of Performance in modern browsers: | ||
| > | ||
| > ```html | ||
| > <h3 id="performance"></h3> | ||
| > | ||
| > <script> | ||
| > performance.innerHTML = "Well Done!"; | ||
| > performance.style.backgroundColor = "green"; | ||
| > </script> | ||
| > ``` |
Member
There was a problem hiding this comment.
I suggest removing this because we can directly build upon the preamble example
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Contributor
Author
Appreciate it! Thanks for the review! |
wbamberg
added a commit
to wbamberg/content
that referenced
this pull request
May 21, 2025
* upstream/main: (40 commits) Add a guide on xs-leaks (mdn#38977) chore: Link to child pages in SVG, URI section (mdn#39470) Correct page title for `Uint8Array.prototype.setFromHex()` (mdn#39494) Bump markdownlint-cli2 from 0.17.2 to 0.18.0 (mdn#39488) Add more documentation for sizes=auto (mdn#39464) css(fix): update 'shape()' page (mdn#39454) Expand Compression Dictionary format description (mdn#39441) Add username/password section to URLs guide (mdn#39487) Fix typos (mdn#39481) CSS: mask-position property description (mdn#39449) Adding @starting-style to CSS nesting at-rules (mdn#39473) feat(aria): Add short titles, format titles for roles (mdn#39472) Fix Circle Collision detection algorithm (mdn#39484) Add warning against using element IDs as global properties. (mdn#39422) Fix typos in web audio spatialization basics (mdn#39476) More Error Messages (mdn#39419) Add links to CSS sidebar (mdn#39445) css: add 'stretch' value examples (mdn#39451) chore: link to unlinked child pages (mdn#39469) Fix typos (mdn#39465) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a warning about using element IDs as global properties on
windowobject, and recommend best practices for safer DOM access.Motivation
Help the readers follow modern standard and best practices when selecting and manipulating element using ID.
Additional details
None.
Related issues and pull requests
Fixes #39339