From edf3b9b7ff42a27d284df574851be3c980237f66 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Thu, 29 Dec 2016 16:31:14 -0800 Subject: [PATCH] Move 'flattenStyle' into 'StyleSheet' --- .../__snapshots__/flattenStyle-test.js.snap | 26 +++++++++++++++++++ .../__tests__/flattenStyle-test.js} | 4 +-- src/apis/StyleSheet/createReactDOMStyle.js | 2 +- .../StyleSheet/flattenStyle.js} | 2 +- src/apis/StyleSheet/index.js | 2 +- .../__snapshots__/index-test.js.snap | 26 ------------------- src/propTypes/StyleSheetPropType.js | 4 +-- 7 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 src/apis/StyleSheet/__tests__/__snapshots__/flattenStyle-test.js.snap rename src/{modules/flattenStyle/__tests__/index-test.js => apis/StyleSheet/__tests__/flattenStyle-test.js} (93%) rename src/{modules/flattenStyle/index.js => apis/StyleSheet/flattenStyle.js} (93%) delete mode 100644 src/modules/flattenStyle/__tests__/__snapshots__/index-test.js.snap diff --git a/src/apis/StyleSheet/__tests__/__snapshots__/flattenStyle-test.js.snap b/src/apis/StyleSheet/__tests__/__snapshots__/flattenStyle-test.js.snap new file mode 100644 index 00000000..1fc54536 --- /dev/null +++ b/src/apis/StyleSheet/__tests__/__snapshots__/flattenStyle-test.js.snap @@ -0,0 +1,26 @@ +exports[`apis/StyleSheet/flattenStyle should merge style objects 1`] = ` +Object { + "opacity": 1, + "order": 2, +} +`; + +exports[`apis/StyleSheet/flattenStyle should override style properties 1`] = ` +Object { + "backgroundColor": "#023c69", + "order": null, +} +`; + +exports[`apis/StyleSheet/flattenStyle should overwrite properties with \`undefined\` 1`] = ` +Object { + "backgroundColor": undefined, +} +`; + +exports[`apis/StyleSheet/flattenStyle should recursively flatten arrays 1`] = ` +Object { + "opacity": 1, + "order": 3, +} +`; diff --git a/src/modules/flattenStyle/__tests__/index-test.js b/src/apis/StyleSheet/__tests__/flattenStyle-test.js similarity index 93% rename from src/modules/flattenStyle/__tests__/index-test.js rename to src/apis/StyleSheet/__tests__/flattenStyle-test.js index 818e5216..eb36a651 100644 --- a/src/modules/flattenStyle/__tests__/index-test.js +++ b/src/apis/StyleSheet/__tests__/flattenStyle-test.js @@ -9,9 +9,9 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -import flattenStyle from '..'; +import flattenStyle from '../flattenStyle'; -describe('modules/flattenStyle', () => { +describe('apis/StyleSheet/flattenStyle', () => { test('should merge style objects', () => { const style = flattenStyle([ { opacity: 1 }, diff --git a/src/apis/StyleSheet/createReactDOMStyle.js b/src/apis/StyleSheet/createReactDOMStyle.js index a6e44281..2c306af6 100644 --- a/src/apis/StyleSheet/createReactDOMStyle.js +++ b/src/apis/StyleSheet/createReactDOMStyle.js @@ -1,5 +1,5 @@ import expandStyle from './expandStyle'; -import flattenStyle from '../../modules/flattenStyle'; +import flattenStyle from './flattenStyle'; import i18nStyle from './i18nStyle'; import processBoxShadow from './processBoxShadow'; import processTextShadow from './processTextShadow'; diff --git a/src/modules/flattenStyle/index.js b/src/apis/StyleSheet/flattenStyle.js similarity index 93% rename from src/modules/flattenStyle/index.js rename to src/apis/StyleSheet/flattenStyle.js index 7b9265c4..f9e2d64e 100644 --- a/src/modules/flattenStyle/index.js +++ b/src/apis/StyleSheet/flattenStyle.js @@ -12,7 +12,7 @@ */ 'use strict'; -var ReactNativePropRegistry = require('../ReactNativePropRegistry'); +var ReactNativePropRegistry = require('../../modules/ReactNativePropRegistry'); var invariant = require('fbjs/lib/invariant'); function getStyle(style) { diff --git a/src/apis/StyleSheet/index.js b/src/apis/StyleSheet/index.js index 3941847a..7269936e 100644 --- a/src/apis/StyleSheet/index.js +++ b/src/apis/StyleSheet/index.js @@ -1,7 +1,7 @@ import * as css from './css'; import createReactDOMStyle from './createReactDOMStyle'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; -import flattenStyle from '../../modules/flattenStyle'; +import flattenStyle from './flattenStyle'; import React from 'react'; import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry'; diff --git a/src/modules/flattenStyle/__tests__/__snapshots__/index-test.js.snap b/src/modules/flattenStyle/__tests__/__snapshots__/index-test.js.snap deleted file mode 100644 index 87c4aaba..00000000 --- a/src/modules/flattenStyle/__tests__/__snapshots__/index-test.js.snap +++ /dev/null @@ -1,26 +0,0 @@ -exports[`modules/flattenStyle should merge style objects 1`] = ` -Object { - "opacity": 1, - "order": 2, -} -`; - -exports[`modules/flattenStyle should override style properties 1`] = ` -Object { - "backgroundColor": "#023c69", - "order": null, -} -`; - -exports[`modules/flattenStyle should overwrite properties with \`undefined\` 1`] = ` -Object { - "backgroundColor": undefined, -} -`; - -exports[`modules/flattenStyle should recursively flatten arrays 1`] = ` -Object { - "opacity": 1, - "order": 3, -} -`; diff --git a/src/propTypes/StyleSheetPropType.js b/src/propTypes/StyleSheetPropType.js index bd43c383..7209cfa1 100644 --- a/src/propTypes/StyleSheetPropType.js +++ b/src/propTypes/StyleSheetPropType.js @@ -7,7 +7,7 @@ module.exports = process.env.NODE_ENV !== 'production' ? function StyleSheetPropType(shape) { const createStrictShapeTypeChecker = require('./createStrictShapeTypeChecker'); - const flattenStyle = require('../modules/flattenStyle'); + const StyleSheet = require('../apis/StyleSheet'); const shapePropType = createStrictShapeTypeChecker(shape); return function (props, propName, componentName, location?) { @@ -15,7 +15,7 @@ module.exports = process.env.NODE_ENV !== 'production' ? function StyleSheetProp if (props[propName]) { // Just make a dummy prop object with only the flattened style newProps = {}; - newProps[propName] = flattenStyle(props[propName]); + newProps[propName] = StyleSheet.flatten(props[propName]); } return shapePropType(newProps, propName, componentName, location); };