From 9a15d994d2994fca8c3da0404f4bdb7377f9704b Mon Sep 17 00:00:00 2001 From: Naman Goel Date: Thu, 4 Apr 2024 03:06:48 -0700 Subject: [PATCH] chore: Split out data attributes to separate files --- .../src/shared/strictAttributes.js | 7 ++++--- .../src/shared/strictDataAttributes.js | 14 ++++++++++++++ .../src/types/StrictReactDOMDataAttrs.js | 14 ++++++++++++++ .../src/types/StrictReactDOMProps.js | 5 ++--- 4 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 packages/react-strict-dom/src/shared/strictDataAttributes.js create mode 100644 packages/react-strict-dom/src/types/StrictReactDOMDataAttrs.js diff --git a/packages/react-strict-dom/src/shared/strictAttributes.js b/packages/react-strict-dom/src/shared/strictAttributes.js index 7ff81fb..b2bc859 100644 --- a/packages/react-strict-dom/src/shared/strictAttributes.js +++ b/packages/react-strict-dom/src/shared/strictAttributes.js @@ -7,7 +7,10 @@ * @flow strict */ +import { strictDataAttributeKeys } from './strictDataAttributes'; + export const strictAttributeSet: Set = new Set([ + ...strictDataAttributeKeys, 'alt', // img 'aria-activedescendant', 'aria-atomic', @@ -62,7 +65,7 @@ export const strictAttributeSet: Set = new Set([ 'checked', // input 'children', 'crossOrigin', // img - 'data-testid', + 'decoding', // img 'defaultChecked', // input 'defaultValue', // input, textarea @@ -142,8 +145,6 @@ export const strictAttributeSet: Set = new Set([ 'value', // input 'width', // img - 'data-imgperflogname', // TEMPORARY - 'data-visualcompletion', // TEMPORARY 'onMouseDown', // TEMPORARY 'onMouseEnter', // TEMPORARY 'onMouseLeave', // TEMPORARY diff --git a/packages/react-strict-dom/src/shared/strictDataAttributes.js b/packages/react-strict-dom/src/shared/strictDataAttributes.js new file mode 100644 index 0000000..e664a27 --- /dev/null +++ b/packages/react-strict-dom/src/shared/strictDataAttributes.js @@ -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 = [ + 'data-testid', + 'data-imgperflogname', // TEMPORARY + 'data-visualcompletion' // TEMPORARY +]; diff --git a/packages/react-strict-dom/src/types/StrictReactDOMDataAttrs.js b/packages/react-strict-dom/src/types/StrictReactDOMDataAttrs.js new file mode 100644 index 0000000..3677a22 --- /dev/null +++ b/packages/react-strict-dom/src/types/StrictReactDOMDataAttrs.js @@ -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 +}>; diff --git a/packages/react-strict-dom/src/types/StrictReactDOMProps.js b/packages/react-strict-dom/src/types/StrictReactDOMProps.js index de94d8a..7883847 100644 --- a/packages/react-strict-dom/src/types/StrictReactDOMProps.js +++ b/packages/react-strict-dom/src/types/StrictReactDOMProps.js @@ -8,6 +8,7 @@ */ import type { StrictElement } from './StrictElement'; +import type { DataAttrs } from './StrictReactDOMDataAttrs'; import type { ReactRef } from './Utilities'; import type { Styles } from './styles'; @@ -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?: