Repository navigation
Conversation
|
Size Change: -1.81 kB (-1.87%) Total Size: 94.8 kB 📦 View Changed
|
Kudo
left a comment
There was a problem hiding this comment.
Summary
The switch to real CSS logical properties is coherent: aliases are normalized before compile, static rules use a numeric precedence ladder, and the documented removals (dir/lang, useLocaleContext, StyleSheet.resolve options, unstable_createElement options) match the code. Static StyleSheet.create output should follow that ladder because each property is its own rule. Inline styles do not. createReactDOMStyle still writes both a physical property and the logical property that maps to the same side, then keeps source key order, so the used value changes with object order and does not match the longhand rule the new helper claims to implement.
Issue counts by severity
- bugs: 1
- suggestions: 1
- nits: 0
| } | ||
| } | ||
|
|
||
| if (style[prop] == null) { |
There was a problem hiding this comment.
[bug] Inline expansion does not keep a stable winner when a physical property and a logical property map to the same side. setLongForm only suppresses same-family keys. An axis shorthand such as marginInline is exempt from that check, so { marginLeft: 8, marginInline: 16 } becomes { marginLeft: '8px', marginInlineStart: '16px', marginInlineEnd: '16px' }. Those are assigned in insertion order, and the later declaration wins for the shared side, so in LTR the shorthand's margin-inline-start overrides the longhand. The reverse key order lets marginLeft win. The logical rewrite has the same hole: if any logical longhand in the group is set, line 325 renames the opposite side before the style[prop] == null check, so { marginBottom: 4, margin: 16, marginBlockStart: 8 } emits both marginBottom: '4px' and marginBlockEnd: '16px'. When margin is expanded after marginBottom, margin-block-end overrides the physical longhand. Explicit pairs such as marginLeft plus marginStart (marginInlineStart after preprocess) never enter setLongForm and have the same order dependence. Same-family tests already require precedence to ignore key order, and the comment on setLongForm says longhands win. Static rules do not use this order either: marginLeft is group 3, marginHorizontal is 2.3, and marginInlineStart is 2.2, so a physical longhand always beats a logical longhand. Inline styles currently follow a third rule.
Suggestion: After expansion, give the inline object one declaration order that does not depend on input key order. Match the static ladder (four-side shorthand, then logical axis, then logical longhands, then physical axis shorthands, then physical longhands) so the higher-precedence property is assigned last and wins on the shared side in both directions. When renaming a side to its logical longhand, still treat an explicit physical longhand on that side as occupying the slot. Add order-independent tests for marginLeft with marginInline / marginStart, marginHorizontal with marginInlineStart, and marginBottom with margin plus marginBlockStart.
Related: react/react-native#59404
marginStart,paddingEnd,start,borderTopStartRadius,textAlign: 'start'…) as CSS logical properties. The browser resolves them from the element's direction.marginHorizontal,marginVertical,paddingHorizontalandpaddingVerticalphysical shorthands, separate frommarginInlineandmarginBlock(I will suggest a similar behavior in React Native, as it's confusing - or maybe we could deprecatemarginHorizontal,marginVerticaletc, we will see).directionstyle (only used for local overrides, the preferred solution is to set bothdirandlangon the document).gapin rule ordering and inline styles.transitionPropertyto CSS logical names.BREAKING CHANGES
dirandlangprops, and the internaldir="auto"onTextandTextInput. Use thedirectionstyle or setdiron the document.useLocaleContext.writingDirection,shadowandtextShadowoptions fromStyleSheet.resolve.unstable_createElementsignature is now(component, props, ...children)(similar toReact.createElement).marginHorizontal(and the other physical axis shorthands) now take precedence overmarginInlineand logical longforms.