Move 'flattenStyle' into 'StyleSheet'

This commit is contained in:
Nicolas Gallagher
2016-12-29 16:31:14 -08:00
parent 518a85bf1b
commit edf3b9b7ff
7 changed files with 33 additions and 33 deletions
@@ -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,
}
`;
@@ -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 },
+1 -1
View File
@@ -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';
@@ -12,7 +12,7 @@
*/
'use strict';
var ReactNativePropRegistry = require('../ReactNativePropRegistry');
var ReactNativePropRegistry = require('../../modules/ReactNativePropRegistry');
var invariant = require('fbjs/lib/invariant');
function getStyle(style) {
+1 -1
View File
@@ -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';
@@ -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,
}
`;
+2 -2
View File
@@ -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);
};