mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
09d420707f
Summary: This updates `fontVariant` to support space-separated string values, i.e., `'small-caps common-ligatures'`, thus aligning it with the [CSS Fonts Module Level 4](https://drafts.csswg.org/css-fonts/#font-variant-prop) specification as requested on https://github.com/facebook/react-native/issues/34425. This also adds unit tests to the `processFontVariant` function ensuring the style processing works as expected. ## Changelog [General] [Added] - Add space-separated string support for fontVariant Pull Request resolved: https://github.com/facebook/react-native/pull/34641 Test Plan: This can be tested either through `processFontVariant-tests` or by using the following code: ```js <Text style={{ fontVariant: 'small-caps common-ligatures', }} /> ``` Reviewed By: javache Differential Revision: D39423317 Pulled By: cipolleschi fbshipit-source-id: ad971addb423ed338e178528a11fe9d456c03e6e
31 lines
676 B
JavaScript
31 lines
676 B
JavaScript
/**
|
|
* 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.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import type {____FontVariantArray_Internal} from './StyleSheetTypes';
|
|
|
|
function processFontVariant(
|
|
fontVariant: ____FontVariantArray_Internal | string,
|
|
): ?____FontVariantArray_Internal {
|
|
if (Array.isArray(fontVariant)) {
|
|
return fontVariant;
|
|
}
|
|
|
|
// $FlowFixMe[incompatible-type]
|
|
const match: ?____FontVariantArray_Internal = fontVariant
|
|
.split(' ')
|
|
.filter(Boolean);
|
|
|
|
return match;
|
|
}
|
|
|
|
module.exports = processFontVariant;
|