Skip to content
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

A11y: Add types #19096

Merged
merged 3 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/a11y/src/addContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @param {string} ariaLive Optional. Value for the 'aria-live' attribute, default 'polite'.
*
* @return {Object} $container The ARIA live region jQuery object.
* @return {HTMLDivElement} The ARIA live region HTML element.
*/
const addContainer = function( ariaLive ) {
ariaLive = ariaLive || 'polite';
Expand All @@ -29,7 +29,11 @@ const addContainer = function( ariaLive ) {
container.setAttribute( 'aria-relevant', 'additions text' );
container.setAttribute( 'aria-atomic', 'true' );

document.querySelector( 'body' ).appendChild( container );
const body = document.querySelector( 'body' );
if ( body ) {
body.appendChild( container );
}

return container;
};

Expand Down
8 changes: 4 additions & 4 deletions packages/a11y/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import filterMessage from './filterMessage';
* Create the live regions.
*/
export const setup = function() {
let containerPolite = document.getElementById( 'a11y-speak-polite' );
let containerAssertive = document.getElementById( 'a11y-speak-assertive' );
const containerPolite = document.getElementById( 'a11y-speak-polite' );
const containerAssertive = document.getElementById( 'a11y-speak-assertive' );

if ( containerPolite === null ) {
containerPolite = addContainer( 'polite' );
addContainer( 'polite' );
}
if ( containerAssertive === null ) {
containerAssertive = addContainer( 'assertive' );
addContainer( 'assertive' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the reassignment of the local variables which seems to serve no purpose here.

}
};

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
},
"include": [
"./packages/a11y/**/*.js",
"./packages/blob/**/*.js",
"./packages/dom-ready/**/*.js",
"./packages/i18n/**/*.js",
Expand Down