From dcce72b66e6604dc2cb8104f43568b0b43190877 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Mon, 22 Jan 2018 10:10:33 -0800 Subject: [PATCH] Reorganize style resolver The style resolver is reorganized to remove React Native style registration, and contain all the stateful resolver logic (previously partially found in NativeMethodsMixin). Style registration is done in 'StyleSheet.create', and will subsequently be decoupled from eager style resolution. The stateful resolver is fully contained in the ReactNativeStyleResolver. The options are removed from the resolver as they aren't needed to implement the correct i18n-ified styles. This functionality is also covered by unit tests now. --- .../renderApplication-test.js.snap | 18 +-- ...egistry.js => ReactNativeStyleResolver.js} | 105 +++++++++------ .../exports/StyleSheet/StyleSheetManager.js | 61 +++------ .../src/exports/StyleSheet/WebStyleSheet.js | 15 ++- .../ReactNativeStyleResolver-test.js | 125 ++++++++++++++++++ .../__tests__/StyleSheetManager-test.js | 14 +- .../__tests__/StyleSheetRegistry-test.js | 109 --------------- ... => ReactNativeStyleResolver-test.js.snap} | 51 ++++--- .../StyleSheetManager-test.js.snap | 12 +- .../createReactDOMStyle-test.js.snap | 8 +- .../createRuleBlock-test.js.snap | 3 + .../__snapshots__/flattenStyle-test.js.snap | 8 +- .../__snapshots__/generateCss-test.js.snap | 3 - .../__snapshots__/i18nStyle-test.js.snap | 4 +- .../__snapshots__/index-test.js.snap | 20 +-- .../__tests__/createReactDOMStyle-test.js | 2 +- ...ateCss-test.js => createRuleBlock-test.js} | 6 +- .../StyleSheet/__tests__/flattenStyle-test.js | 2 +- .../StyleSheet/__tests__/i18nStyle-test.js | 2 +- .../StyleSheet/__tests__/index-test.js | 2 +- .../__tests__/normalizeValue-test.js | 2 +- .../exports/StyleSheet/createAtomicRules.js | 31 +++++ .../{generateCss.js => createRuleBlock.js} | 0 .../src/exports/StyleSheet/index.js | 12 +- .../src/exports/StyleSheet/initialRules.js | 22 +-- .../{registry.js => styleResolver.js} | 6 +- .../src/modules/NativeMethodsMixin/index.js | 34 +---- .../src/modules/createDOMProps/index.js | 4 +- 28 files changed, 365 insertions(+), 316 deletions(-) rename packages/react-native-web/src/exports/StyleSheet/{StyleSheetRegistry.js => ReactNativeStyleResolver.js} (73%) create mode 100644 packages/react-native-web/src/exports/StyleSheet/__tests__/ReactNativeStyleResolver-test.js delete mode 100644 packages/react-native-web/src/exports/StyleSheet/__tests__/StyleSheetRegistry-test.js rename packages/react-native-web/src/exports/StyleSheet/__tests__/__snapshots__/{StyleSheetRegistry-test.js.snap => ReactNativeStyleResolver-test.js.snap} (73%) create mode 100644 packages/react-native-web/src/exports/StyleSheet/__tests__/__snapshots__/createRuleBlock-test.js.snap delete mode 100644 packages/react-native-web/src/exports/StyleSheet/__tests__/__snapshots__/generateCss-test.js.snap rename packages/react-native-web/src/exports/StyleSheet/__tests__/{generateCss-test.js => createRuleBlock-test.js} (63%) create mode 100644 packages/react-native-web/src/exports/StyleSheet/createAtomicRules.js rename packages/react-native-web/src/exports/StyleSheet/{generateCss.js => createRuleBlock.js} (100%) rename packages/react-native-web/src/exports/StyleSheet/{registry.js => styleResolver.js} (60%) diff --git a/packages/react-native-web/src/exports/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap b/packages/react-native-web/src/exports/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap index bec1e11e..764df863 100644 --- a/packages/react-native-web/src/exports/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap +++ b/packages/react-native-web/src/exports/AppRegistry/__tests__/__snapshots__/renderApplication-test.js.snap @@ -9,17 +9,14 @@ exports[`apis/AppRegistry/renderApplication getApplication 1`] = ` `; exports[`apis/AppRegistry/renderApplication getApplication 2`] = ` -"