Repository navigation
Conversation
…values LENGTH_REG only accepted unsigned integers, and the color was assumed to be the last token. As a result: - "2px -2px" used "-2px" as the color - "1px 1px 1.5px" used "1.5px" as the color - "red 1px 2px 3px" used "red" as offsetX and shifted the other values Accept signed and decimal lengths, take the first non-length token as the color wherever it appears, and ignore empty tokens from repeated spaces.
In dark mode, resolveVariableReferenceValue always read the '@media (prefers-color-scheme: dark)' key. A variable defined without it resolved to undefined, so the whole style property was dropped. Only use the dark value when it is defined, matching how regular style values are resolved in css/index.js.
|
Hi @kirawth! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
Two small fixes in the native CSS layer, one commit each.
1.
textShadowmisparses common valid valuesLENGTH_REG(/^[0-9]+[a-zA-Z%]+?$/) only accepted unsigned integers, and the color was assumed to be the last token:2px -2px"-2px", heightundefined1px 1px 1.5px"1.5px", radiusundefinedred 1px 2px 3px"red", height1, radius2CSS allows the color before or after the lengths, and offsets can be negative. The fix:
-?([0-9]*\.)?[0-9]+unit)2. Variables without a dark value resolve to nothing in dark mode
In
resolveVariableReferenceValue, dark mode always readvariableValue['@media (prefers-color-scheme: dark)']. Take a variable defined as{ default: 'black', '@media (min-width: 400px)': 'gray' }, or any object value without a dark key. In dark mode it resolved toundefined,resolveVariableReferencesreturnednull, and the style property was dropped.It now uses the dark value only when it's defined (
Object.hasOwn). That matches how regular style values handlemqDarkincss/index.js.Test plan
__tests__/parseTextShadow-test.js: color last, color first, functional colors, negative and decimal lengths, repeated whitespace.__tests__/customProperties-test.js: dark value used when present, default used when absent.