Skip to content

Commit 1acae07

Browse files
committed
Remove logical styles shim
See #35342
1 parent 21f6db7 commit 1acae07

File tree

11 files changed

+24
-181
lines changed

11 files changed

+24
-181
lines changed

Libraries/Components/TextInput/TextInput.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import type {TextInputType} from './TextInput.flow';
1919

2020
import usePressability from '../../Pressability/usePressability';
2121
import flattenStyle from '../../StyleSheet/flattenStyle';
22-
import processStyles from '../../StyleSheet/processStyles';
2322
import StyleSheet, {
2423
type ColorValue,
2524
type TextStyleProp,
@@ -1420,19 +1419,15 @@ function InternalTextInput(props: Props): React.Node {
14201419
};
14211420
}
14221421

1422+
let style = flattenStyle(props.style);
1423+
14231424
if (Platform.OS === 'ios') {
14241425
const RCTTextInputView =
14251426
props.multiline === true
14261427
? RCTMultilineTextInputView
14271428
: RCTSinglelineTextInputView;
14281429

1429-
let style =
1430-
props.multiline === true
1431-
? [styles.multilineInput, props.style]
1432-
: props.style;
1433-
1434-
style = flattenStyle(style);
1435-
style = processStyles(style);
1430+
style = props.multiline === true ? [styles.multilineInput, style] : style;
14361431

14371432
const useOnChangeSync =
14381433
(props.unstable_onChangeSync || props.unstable_onChangeTextSync) &&
@@ -1465,9 +1460,6 @@ function InternalTextInput(props: Props): React.Node {
14651460
/>
14661461
);
14671462
} else if (Platform.OS === 'android') {
1468-
let style = flattenStyle(props.style);
1469-
style = processStyles(style);
1470-
14711463
const autoCapitalize = props.autoCapitalize || 'sentences';
14721464
const _accessibilityLabelledBy =
14731465
props?.['aria-labelledby'] ?? props?.accessibilityLabelledBy;
@@ -1635,11 +1627,12 @@ const ExportedForwardRef: React.AbstractComponent<
16351627
React.ElementRef<HostComponent<mixed>> & ImperativeMethods,
16361628
>,
16371629
) {
1638-
const style = flattenStyle(restProps.style);
1630+
let style = flattenStyle(restProps.style);
16391631

16401632
if (style?.verticalAlign != null) {
16411633
style.textAlignVertical =
16421634
verticalAlignToTextAlignVerticalMap[style.verticalAlign];
1635+
delete style.verticalAlign;
16431636
}
16441637

16451638
return (

Libraries/Components/TextInput/__tests__/TextInput-test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ describe('TextInput', () => {
207207
onStartShouldSetResponder={[Function]}
208208
rejectResponderTermination={true}
209209
selection={null}
210-
style={Object {}}
211210
submitBehavior="blurAndSubmit"
212211
text=""
213212
underlineColorAndroid="transparent"
@@ -254,7 +253,6 @@ describe('TextInput compat with web', () => {
254253
onStartShouldSetResponder={[Function]}
255254
rejectResponderTermination={true}
256255
selection={null}
257-
style={Object {}}
258256
submitBehavior="blurAndSubmit"
259257
tabIndex={0}
260258
testID="testID"
@@ -394,7 +392,6 @@ describe('TextInput compat with web', () => {
394392
rejectResponderTermination={true}
395393
role="main"
396394
selection={null}
397-
style={Object {}}
398395
submitBehavior="blurAndSubmit"
399396
text=""
400397
underlineColorAndroid="transparent"
@@ -442,7 +439,7 @@ describe('TextInput compat with web', () => {
442439
"backgroundColor": "white",
443440
"display": "flex",
444441
"flex": 1,
445-
"marginStart": 10,
442+
"marginInlineStart": 10,
446443
"textAlignVertical": "center",
447444
"userSelect": "none",
448445
}

Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ exports[`TextInput tests should render as expected: should deep render when mock
2323
onStartShouldSetResponder={[Function]}
2424
rejectResponderTermination={true}
2525
selection={null}
26-
style={Object {}}
2726
submitBehavior="blurAndSubmit"
2827
text=""
2928
underlineColorAndroid="transparent"
@@ -53,7 +52,6 @@ exports[`TextInput tests should render as expected: should deep render when not
5352
onStartShouldSetResponder={[Function]}
5453
rejectResponderTermination={true}
5554
selection={null}
56-
style={Object {}}
5755
submitBehavior="blurAndSubmit"
5856
text=""
5957
underlineColorAndroid="transparent"

Libraries/Components/View/View.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import type {ViewProps} from './ViewPropTypes';
1212

1313
import flattenStyle from '../../StyleSheet/flattenStyle';
14-
import processStyles from '../../StyleSheet/processStyles';
1514
import TextAncestor from '../../Text/TextAncestor';
1615
import {getAccessibilityRoleFromRole} from '../../Utilities/AcessibilityMapping';
1716
import ViewNativeComponent from './ViewNativeComponent';
@@ -100,7 +99,6 @@ const View: React.AbstractComponent<
10099
}
101100

102101
let style = flattenStyle(otherProps.style);
103-
style = processStyles(style);
104102

105103
const newPointerEvents = style?.pointerEvents || pointerEvents;
106104

Libraries/Components/View/__tests__/View-test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ describe('View', () => {
2121
it('default render', () => {
2222
const instance = render.create(<View />);
2323

24-
expect(instance.toJSON()).toMatchInlineSnapshot(`
25-
<RCTView
26-
style={Object {}}
27-
/>
28-
`);
24+
expect(instance.toJSON()).toMatchInlineSnapshot(`<RCTView />`);
2925
});
3026

3127
it('has displayName', () => {
@@ -47,7 +43,6 @@ describe('View compat with web', () => {
4743
<RCTView
4844
focusable={true}
4945
nativeID="id"
50-
style={Object {}}
5146
testID="testID"
5247
/>
5348
`);
@@ -165,7 +160,6 @@ describe('View compat with web', () => {
165160
aria-setsize={5}
166161
aria-sort="ascending"
167162
importantForAccessibility="no-hide-descendants"
168-
style={Object {}}
169163
/>
170164
`);
171165
});
@@ -189,7 +183,7 @@ describe('View compat with web', () => {
189183
"backgroundColor": "white",
190184
"display": "flex",
191185
"flex": 1,
192-
"marginStart": 10,
186+
"marginInlineStart": 10,
193187
"pointerEvents": "none",
194188
}
195189
}

Libraries/Image/Image.android.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {ImageAndroid} from './Image.flow';
1313
import type {ImageProps as ImagePropsType} from './ImageProps';
1414

1515
import flattenStyle from '../StyleSheet/flattenStyle';
16-
import processStyles from '../StyleSheet/processStyles';
1716
import StyleSheet from '../StyleSheet/StyleSheet';
1817
import TextAncestor from '../Text/TextAncestor';
1918
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
@@ -159,16 +158,13 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
159158
const {width = props.width, height = props.height, uri} = source;
160159
style = flattenStyle([{width, height}, styles.base, props.style]);
161160
sources = [source];
162-
163161
if (uri === '') {
164162
console.warn('source.uri should not be an empty string');
165163
}
166164
}
167165

168166
const {height, width, ...restProps} = props;
169167

170-
style = processStyles(style);
171-
172168
const {onLoadStart, onLoad, onLoadEnd, onError} = props;
173169
const nativeProps = {
174170
...restProps,

Libraries/Image/Image.ios.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {ImageIOS} from './Image.flow';
1414
import type {ImageProps as ImagePropsType} from './ImageProps';
1515

1616
import flattenStyle from '../StyleSheet/flattenStyle';
17-
import processStyles from '../StyleSheet/processStyles';
1817
import StyleSheet from '../StyleSheet/StyleSheet';
1918
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
2019
import ImageInjection from './ImageInjection';
@@ -138,8 +137,6 @@ const BaseImage = (props: ImagePropsType, forwardedRef) => {
138137
// $FlowFixMe[prop-missing]
139138
const tintColor = props.tintColor || style.tintColor;
140139

141-
style = processStyles(style);
142-
143140
if (props.children != null) {
144141
throw new Error(
145142
'The <Image> component cannot contain children. If you want to render content on top of the image, consider using the <ImageBackground> component or absolute positioning.',

Libraries/StyleSheet/__tests__/processStyles-test.js

Lines changed: 0 additions & 78 deletions
This file was deleted.

Libraries/StyleSheet/processStyles.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

Libraries/Text/Text.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
1515
import usePressability from '../Pressability/usePressability';
1616
import flattenStyle from '../StyleSheet/flattenStyle';
1717
import processColor from '../StyleSheet/processColor';
18-
import processStyles from '../StyleSheet/processStyles';
18+
import StyleSheet from '../StyleSheet/StyleSheet';
1919
import {getAccessibilityRoleFromRole} from '../Utilities/AcessibilityMapping';
2020
import Platform from '../Utilities/Platform';
2121
import TextAncestor from './TextAncestor';
@@ -209,7 +209,6 @@ const Text: React.AbstractComponent<
209209
});
210210

211211
style = flattenStyle(style);
212-
style = processStyles(style);
213212

214213
if (typeof style?.fontWeight === 'number') {
215214
style.fontWeight = style?.fontWeight.toString();
@@ -218,6 +217,13 @@ const Text: React.AbstractComponent<
218217
let _selectable = restProps.selectable;
219218
if (style?.userSelect != null) {
220219
_selectable = userSelectToSelectableMap[style.userSelect];
220+
delete style.userSelect;
221+
}
222+
223+
if (style?.verticalAlign != null) {
224+
style.textAlignVertical =
225+
verticalAlignToTextAlignVerticalMap[style.verticalAlign];
226+
delete style.verticalAlign;
221227
}
222228

223229
const _hasOnPressOrOnLongPress =
@@ -300,4 +306,11 @@ const userSelectToSelectableMap = {
300306
all: true,
301307
};
302308

309+
const verticalAlignToTextAlignVerticalMap = {
310+
auto: 'auto',
311+
top: 'top',
312+
bottom: 'bottom',
313+
middle: 'center',
314+
};
315+
303316
module.exports = Text;

0 commit comments

Comments
 (0)