-
-
Notifications
You must be signed in to change notification settings - Fork 981
Check for duplicate iframe IDs #1546
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9d4d2ac
Check for duplicate iframe IDs
davidjbradshaw ee21f67
Update packages/core/index.js
davidjbradshaw 739f83c
Tidy
davidjbradshaw 2dcb974
Fix: Only encode strings
davidjbradshaw a1b8721
Format all string fields passed to advise
davidjbradshaw 2dd29e9
type check input to remove()
davidjbradshaw 5adb7ca
Tidy map functions
davidjbradshaw 7fe67b8
Move `checkUniqueId()` to own file
davidjbradshaw 4a244c1
Add NEW_LINE const
davidjbradshaw d2f82ba
Add <bb> to advise formatter
davidjbradshaw 1e41ddf
Stop warning displaying twice
davidjbradshaw 2ef53e0
Update packages/core/unique.js
davidjbradshaw 66e1852
Potential fix for code scanning alert no. 576: Incomplete multi-chara…
davidjbradshaw f4b1547
Tidy Co-Pilot review
davidjbradshaw 141838e
Update packages/common/format-advise.js
davidjbradshaw 55c4c4e
Update packages/core/console.js
davidjbradshaw 1fccb22
Tidy
davidjbradshaw 164a0da
Add colour to timeout warning
davidjbradshaw 1e0e304
Apply suggestion from @Copilot
davidjbradshaw 502d367
tidy
davidjbradshaw cf59b42
Tidy
davidjbradshaw e9acf74
tidy
davidjbradshaw 2b49931
Store advise tags in an object
davidjbradshaw de0aa67
delint
davidjbradshaw 91a36c0
delint
davidjbradshaw 0f44eee
tidy
davidjbradshaw 2ca8030
Tidy
davidjbradshaw 60b3299
Tidy RegExp
davidjbradshaw 34898a3
Tidy
davidjbradshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { NEW_LINE } from '../common/consts' | ||
| import { advise } from './console' | ||
|
|
||
| const shownDuplicateIdWarning = {} | ||
|
|
||
| export default function checkUniqueId(id) { | ||
| if (shownDuplicateIdWarning[id] === true) return false | ||
|
|
||
| const elements = document.querySelectorAll(`iframe#${CSS.escape(id)}`) | ||
davidjbradshaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (elements.length === 1) return true | ||
davidjbradshaw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| shownDuplicateIdWarning[id] = true | ||
|
|
||
| const elementList = Array.from(elements).flatMap((element) => [ | ||
| NEW_LINE, | ||
| element, | ||
| NEW_LINE, | ||
| ]) | ||
|
|
||
| advise( | ||
| id, | ||
| `<rb>Duplicate ID attributes detected</>\n\nThe <b>${id}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value. | ||
| Found <bb>${elements.length}</> iframes with the <b>${id}</> ID:`, | ||
davidjbradshaw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ...elementList, | ||
| NEW_LINE, | ||
| ) | ||
davidjbradshaw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return false | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.