Skip to content

Commit 79e96b5

Browse files
sirrealt-hamanokevin940726colorful-tonesafercia
authored
A11y: Remove redundant styles (#65409)
* Remove redundant CSS styles and spaces * Improve container `ariaLive` parameter type * Use empty string to set boolean attribute This is a minimal way of setting the `hidden` attribute. From MDN: > The hidden attribute is used to indicate that the content of an element should not be presented to the user. This attribute can take any one of the following values: > > - an empty string > - the keyword hidden > - the keyword until-found > > An empty string, or the keyword hidden, set the element to the hidden state. Additionally, invalid values set the element to the hidden state. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/hidden --------- Co-authored-by: sirreal <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: kevin940726 <[email protected]> Co-authored-by: colorful-tones <[email protected]> Co-authored-by: afercia <[email protected]> Co-authored-by: joedolson <[email protected]> Co-authored-by: getdave <[email protected]>
1 parent 51ebf68 commit 79e96b5

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

packages/a11y/src/script/add-container.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Build the live regions markup.
33
*
4-
* @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
4+
* @param {'polite'|'assertive'} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
55
*
66
* @return {HTMLDivElement} The ARIA live region HTML element.
77
*/
@@ -12,17 +12,15 @@ export default function addContainer( ariaLive = 'polite' ) {
1212

1313
container.setAttribute(
1414
'style',
15-
'position: absolute;' +
16-
'margin: -1px;' +
17-
'padding: 0;' +
18-
'height: 1px;' +
19-
'width: 1px;' +
20-
'overflow: hidden;' +
21-
'clip: rect(1px, 1px, 1px, 1px);' +
22-
'-webkit-clip-path: inset(50%);' +
23-
'clip-path: inset(50%);' +
24-
'border: 0;' +
25-
'word-wrap: normal !important;'
15+
'position:absolute;' +
16+
'margin:-1px;' +
17+
'padding:0;' +
18+
'height:1px;' +
19+
'width:1px;' +
20+
'overflow:hidden;' +
21+
'clip-path:inset(50%);' +
22+
'border:0;' +
23+
'word-wrap:normal !important;'
2624
);
2725
container.setAttribute( 'aria-live', ariaLive );
2826
container.setAttribute( 'aria-relevant', 'additions text' );

packages/a11y/src/script/add-intro-text.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,17 @@ export default function addIntroText() {
2020

2121
introText.setAttribute(
2222
'style',
23-
'position: absolute;' +
24-
'margin: -1px;' +
25-
'padding: 0;' +
26-
'height: 1px;' +
27-
'width: 1px;' +
28-
'overflow: hidden;' +
29-
'clip: rect(1px, 1px, 1px, 1px);' +
30-
'-webkit-clip-path: inset(50%);' +
31-
'clip-path: inset(50%);' +
32-
'border: 0;' +
33-
'word-wrap: normal !important;'
23+
'position:absolute;' +
24+
'margin:-1px;' +
25+
'padding:0;' +
26+
'height:1px;' +
27+
'width:1px;' +
28+
'overflow:hidden;' +
29+
'clip-path:inset(50%);' +
30+
'border:0;' +
31+
'word-wrap:normal !important;'
3432
);
35-
introText.setAttribute( 'hidden', 'hidden' );
33+
introText.setAttribute( 'hidden', '' );
3634

3735
const { body } = document;
3836
if ( body ) {

0 commit comments

Comments
 (0)