Skip to content

Commit 4d6ec2a

Browse files
committed
Stop using obsolete closure primitives
Closure compiler looks for these based on the resolved name, which no longer works in es6 modules. So we inline what the compiler would do. - object.create -> object literal - object.createSet -> object literal with `true` values - reflect.objectProperty -> JSCompiler_renameProperty - reflect.object => multiple JSCompiler_renameProperty - add @pureOrBreakMyCode to reflect.cache calls There's no documentation for @pureOrBreakMyCode, but Steve Hicks from Google said that's the correct solution and this seems to be the syntax based on google/closure-compiler#4178 It seems like adding this to reflect.cache itself would work if the call is inlined. However I don't know if that always happens, so I also added it at the callsites.
1 parent 4c4524e commit 4d6ec2a

29 files changed

+1327
-2018
lines changed

closure/goog/a11y/aria/aria.js

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
* performed when adding ARIA to components.
1313
*/
1414

15-
import { Role } from './roles.js';
16-
17-
import { State } from './attributes.js';
18-
import * as datatables from './datatables.js';
1915
import * as array from '../../array/array.js';
2016
import * as asserts from '../../asserts/asserts.js';
2117
import * as dom from '../../dom/dom.js';
22-
import { TagName } from '../../dom/tagname.js';
18+
import {TagName} from '../../dom/tagname.js';
2319
import object from '../../object/object.js';
2420
import * as googString from '../../string/string.js';
2521

22+
import {State} from './attributes.js';
23+
import * as datatables from './datatables.js';
24+
import {Role} from './roles.js';
25+
2626

2727
/**
2828
* ARIA states/properties prefix.
@@ -44,14 +44,25 @@ var ROLE_ATTRIBUTE_ = 'role';
4444
* they don't contain content to be made accessible.
4545
* @private
4646
*/
47-
var TAGS_WITH_ASSUMED_ROLES_ = object.createSet([
48-
TagName.A, TagName.AREA, TagName.BUTTON,
49-
TagName.HEAD, TagName.INPUT, TagName.LINK,
50-
TagName.MENU, TagName.META, TagName.OPTGROUP,
51-
TagName.OPTION, TagName.PROGRESS, TagName.STYLE,
52-
TagName.SELECT, TagName.SOURCE, TagName.TEXTAREA,
53-
TagName.TITLE, TagName.TRACK
54-
]);
47+
var TAGS_WITH_ASSUMED_ROLES_ = {
48+
[TagName.A]: true,
49+
[TagName.AREA]: true,
50+
[TagName.BUTTON]: true,
51+
[TagName.HEAD]: true,
52+
[TagName.INPUT]: true,
53+
[TagName.LINK]: true,
54+
[TagName.MENU]: true,
55+
[TagName.META]: true,
56+
[TagName.OPTGROUP]: true,
57+
[TagName.OPTION]: true,
58+
[TagName.PROGRESS]: true,
59+
[TagName.STYLE]: true,
60+
[TagName.SELECT]: true,
61+
[TagName.SOURCE]: true,
62+
[TagName.TEXTAREA]: true,
63+
[TagName.TITLE]: true,
64+
[TagName.TRACK]: true,
65+
};
5566

5667

5768
/**
@@ -63,13 +74,9 @@ var TAGS_WITH_ASSUMED_ROLES_ = object.createSet([
6374
* @private @const {!Array<Role>}
6475
*/
6576
var CONTAINER_ROLES_ = [
66-
Role.COMBOBOX, Role.GRID,
67-
Role.GROUP, Role.LISTBOX,
68-
Role.MENU, Role.MENUBAR,
69-
Role.RADIOGROUP, Role.ROW,
70-
Role.ROWGROUP, Role.TAB_LIST,
71-
Role.TEXTBOX, Role.TOOLBAR,
72-
Role.TREE, Role.TREEGRID
77+
Role.COMBOBOX, Role.GRID, Role.GROUP, Role.LISTBOX, Role.MENU, Role.MENUBAR,
78+
Role.RADIOGROUP, Role.ROW, Role.ROWGROUP, Role.TAB_LIST, Role.TEXTBOX,
79+
Role.TOOLBAR, Role.TREE, Role.TREEGRID
7380
];
7481

7582

@@ -202,8 +209,7 @@ export function getState(element, stateName) {
202209

203210
var attr =
204211
/** @type {string|number|boolean} */ (
205-
element.getAttribute(
206-
getAriaAttributeName_(stateName)));
212+
element.getAttribute(getAriaAttributeName_(stateName)));
207213
var isNullOrUndefined = attr == null || attr == undefined;
208214
return isNullOrUndefined ? '' : String(attr);
209215
}
@@ -217,8 +223,7 @@ export function getState(element, stateName) {
217223
* @return {?Element} DOM node of the activedescendant, if found.
218224
*/
219225
export function getActiveDescendant(element) {
220-
var id =
221-
getState(element, State.ACTIVEDESCENDANT);
226+
var id = getState(element, State.ACTIVEDESCENDANT);
222227
return dom.getOwnerDocument(element).getElementById(id);
223228
}
224229

@@ -273,8 +278,7 @@ export function assertRoleIsSetInternalUtil(element, allowedRoles) {
273278
return;
274279
}
275280
var elementRole = /** @type {string}*/ (getRole(element));
276-
asserts.assert(
277-
elementRole != null, 'The element ARIA role cannot be null.');
281+
asserts.assert(elementRole != null, 'The element ARIA role cannot be null.');
278282

279283
asserts.assert(
280284
array.contains(allowedRoles, elementRole),
@@ -294,8 +298,8 @@ export function assertRoleIsSetInternalUtil(element, allowedRoles) {
294298
*/
295299
export function getStateBoolean(element, stateName) {
296300
var attr =
297-
/** @type {string|boolean|null} */ (element.getAttribute(
298-
getAriaAttributeName_(stateName)));
301+
/** @type {string|boolean|null} */ (
302+
element.getAttribute(getAriaAttributeName_(stateName)));
299303
asserts.assert(
300304
typeof attr === 'boolean' || attr == null || attr == 'true' ||
301305
attr == 'false');
@@ -315,8 +319,8 @@ export function getStateBoolean(element, stateName) {
315319
*/
316320
export function getStateNumber(element, stateName) {
317321
var attr =
318-
/** @type {string|number} */ (element.getAttribute(
319-
getAriaAttributeName_(stateName)));
322+
/** @type {string|number} */ (
323+
element.getAttribute(getAriaAttributeName_(stateName)));
320324
asserts.assert(
321325
(attr == null || !isNaN(Number(attr))) && typeof attr !== 'boolean');
322326
return attr == null ? null : Number(attr);
@@ -331,8 +335,7 @@ export function getStateNumber(element, stateName) {
331335
* the state value is empty string or not set.
332336
*/
333337
export function getStateString(element, stateName) {
334-
var attr =
335-
element.getAttribute(getAriaAttributeName_(stateName));
338+
var attr = element.getAttribute(getAriaAttributeName_(stateName));
336339
asserts.assert(
337340
(attr == null || typeof attr === 'string') &&
338341
(attr == '' || isNaN(Number(attr))) && attr != 'true' && attr != 'false');
@@ -350,8 +353,7 @@ export function getStateString(element, stateName) {
350353
* value of the state attribute.
351354
*/
352355
export function getStringArrayStateInternalUtil(element, stateName) {
353-
var attrValue =
354-
element.getAttribute(getAriaAttributeName_(stateName));
356+
var attrValue = element.getAttribute(getAriaAttributeName_(stateName));
355357
return splitStringOnWhitespace_(attrValue);
356358
}
357359

0 commit comments

Comments
 (0)