Skip to content

Commit

Permalink
chore: Split out data attributes to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
nmn committed Apr 4, 2024
1 parent 429e2fe commit 9a15d99
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/react-strict-dom/src/shared/strictAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
* @flow strict
*/

import { strictDataAttributeKeys } from './strictDataAttributes';

export const strictAttributeSet: Set<string> = new Set([
...strictDataAttributeKeys,
'alt', // img
'aria-activedescendant',
'aria-atomic',
Expand Down Expand Up @@ -62,7 +65,7 @@ export const strictAttributeSet: Set<string> = new Set([
'checked', // input
'children',
'crossOrigin', // img
'data-testid',

'decoding', // img
'defaultChecked', // input
'defaultValue', // input, textarea
Expand Down Expand Up @@ -142,8 +145,6 @@ export const strictAttributeSet: Set<string> = new Set([
'value', // input
'width', // img

'data-imgperflogname', // TEMPORARY
'data-visualcompletion', // TEMPORARY
'onMouseDown', // TEMPORARY
'onMouseEnter', // TEMPORARY
'onMouseLeave', // TEMPORARY
Expand Down
14 changes: 14 additions & 0 deletions packages/react-strict-dom/src/shared/strictDataAttributes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/

export const strictDataAttributeKeys: $ReadOnlyArray<string> = [
'data-testid',
'data-imgperflogname', // TEMPORARY
'data-visualcompletion' // TEMPORARY
];
14 changes: 14 additions & 0 deletions packages/react-strict-dom/src/types/StrictReactDOMDataAttrs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/

export type DataAttrs = $ReadOnly<{
'data-imgperflogname'?: string, // TEMPORARY
'data-testid'?: string,
'data-visualcompletion'?: string // TEMPORARY
}>;
5 changes: 2 additions & 3 deletions packages/react-strict-dom/src/types/StrictReactDOMProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import type { StrictElement } from './StrictElement';
import type { DataAttrs } from './StrictReactDOMDataAttrs';
import type { ReactRef } from './Utilities';
import type { Styles } from './styles';

Expand Down Expand Up @@ -202,12 +203,10 @@ type EventProps = $ReadOnly<{
export type StrictReactDOMProps = $ReadOnly<{
...AriaProps,
...EventProps,
...DataAttrs,
autoCapitalize?: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters',
autoFocus?: boolean,
children?: React$Node,
'data-imgperflogname'?: string, // TEMPORARY
'data-testid'?: string,
'data-visualcompletion'?: string, // TEMPORARY
dir?: 'auto' | 'ltr' | 'rtl',
elementTiming?: string,
enterKeyHint?:
Expand Down

0 comments on commit 9a15d99

Please sign in to comment.