mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-12 17:45:49 +08:00
This removes the now-obsolete is_legacy_javascript_entrypoint build flag, which was used as part of the devtools_entrypoint migration. This uncovered that accessibility was still using devtools_pre_built and a file was missing from the GRD variable. R=aerotwist@chromium.org,jacktfranklin@chromium.org Fixed: 1101738 Change-Id: Ie1556ccc1d1563c855417de18e896308de0cfe19 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2356305 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org> Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
94 lines
1.9 KiB
JavaScript
94 lines
1.9 KiB
JavaScript
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// @ts-nocheck
|
|
// TODO(crbug.com/1011811): Enable TypeScript compiler checks
|
|
|
|
import * as ARIAProperties from '../generated/ARIAProperties.js';
|
|
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
export class ARIAMetadata {
|
|
/**
|
|
* @param {?Object} config
|
|
*/
|
|
constructor(config) {
|
|
/** @type {!Map<string, !Attribute>} */
|
|
this._attributes = new Map();
|
|
|
|
if (config) {
|
|
this._initialize(config);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {!Object} config
|
|
*/
|
|
_initialize(config) {
|
|
const attributes = config['attributes'];
|
|
|
|
const booleanEnum = ['true', 'false'];
|
|
for (const attributeConfig of attributes) {
|
|
if (attributeConfig.type === 'boolean') {
|
|
attributeConfig.enum = booleanEnum;
|
|
}
|
|
this._attributes.set(attributeConfig.name, new Attribute(attributeConfig));
|
|
}
|
|
|
|
/** @type {!Array<string>} */
|
|
this._roleNames = config['roles'].map(roleConfig => roleConfig.name);
|
|
}
|
|
|
|
/**
|
|
* @param {string} property
|
|
* @return {!Array<string>}
|
|
*/
|
|
valuesForProperty(property) {
|
|
if (this._attributes.has(property)) {
|
|
return this._attributes.get(property).getEnum();
|
|
}
|
|
|
|
if (property === 'role') {
|
|
return this._roleNames;
|
|
}
|
|
|
|
return [];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return {!ARIAMetadata}
|
|
*/
|
|
export function ariaMetadata() {
|
|
if (!ARIAMetadata._instance) {
|
|
ARIAMetadata._instance = new ARIAMetadata(ARIAProperties.config || null);
|
|
}
|
|
return ARIAMetadata._instance;
|
|
}
|
|
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
export class Attribute {
|
|
/**
|
|
* @param {!Object} config
|
|
*/
|
|
constructor(config) {
|
|
/** @type {!Array<string>} */
|
|
this._enum = [];
|
|
|
|
if ('enum' in config) {
|
|
this._enum = config.enum;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return {!Array<string>}
|
|
*/
|
|
getEnum() {
|
|
return this._enum;
|
|
}
|
|
}
|