-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Polish a11y package. #21148
Merged
Merged
Polish a11y package. #21148
Changes from all commits
Commits
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
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
/** | ||
* Clear the a11y-speak-region elements. | ||
*/ | ||
const clear = function() { | ||
const regions = document.querySelectorAll( '.a11y-speak-region' ); | ||
export default function clear() { | ||
const regions = document.getElementsByClassName( 'a11y-speak-region' ); | ||
|
||
for ( let i = 0; i < regions.length; i++ ) { | ||
regions[ i ].textContent = ''; | ||
} | ||
}; | ||
|
||
export default clear; | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import filterMessage from './filterMessage'; | ||
import filterMessage from './filter-message'; | ||
|
||
/** | ||
* Update the ARIA live notification area text node. | ||
* | ||
* @param {string} message The message to be announced by Assistive Technologies. | ||
* @param {string} ariaLive Optional. The politeness level for aria-live. Possible values: | ||
* polite or assertive. Default polite. | ||
* @param {string} [ariaLive] The politeness level for aria-live; default: 'polite'. | ||
*/ | ||
export const speak = function( message, ariaLive ) { | ||
export function speak( message, ariaLive ) { | ||
message = filterMessage( message ); | ||
//TODO: Use native module to speak message | ||
if ( 'assertive' === ariaLive ) { | ||
if ( ariaLive === 'assertive' ) { | ||
} else { | ||
} | ||
}; | ||
} |
This file contains 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 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 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 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
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.
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.
Technically this would previously fall back to
'polite'
for any falsy value given (null
,false
,0
, etc), and now it will only fall back when explicitlyundefined
(omitted). Generally speaking, I think this is a fine approach, but it may be something to consider for potential side-effects.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.
Yeah, I generally lean towards enforcing that functions only be called with certain types, so in this case I'd consider calling this function with anything other than one of the 2 valid strings or
undefined
to be an error that should be caught by the linter/compiler.I initially tried to use a type union of
('assertive'|'polite')
as theariaLive
JSDoc type, but despite something similar appearing as an example in our docs, the auto-generated docs weren't handling it properly and was just outputting(|)
. I'm going to make another PR for that change later and see if anyone can figure out how to fix the issue.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.
Yeah, this is related to the issue described at #18045, and tangentially #19952 (#19952 (comment)).