mirror of
https://github.com/status-im/react-native.git
synced 2025-01-11 10:06:31 +00:00
a8e3c7f578
Summary: Changed StyleSheet.create to be the identity function. We no longer hide it behind an opaque number. Better for types and perf since we don't use it. I don't really know if we have/need any safer way of rolling this out than just landing it. It can break if the object passed to StyleSheet.create is mutated afterwards but that isn't a practice anywhere I've seen. Reviewed By: sophiebits Differential Revision: D7530023 fbshipit-source-id: bc1afa879c5a5d9cd95cb13bc8ff3347b3622851
42 lines
893 B
JavaScript
42 lines
893 B
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @providesModule flattenStyle
|
|
* @flow
|
|
* @format
|
|
*/
|
|
'use strict';
|
|
|
|
import type {
|
|
DangerouslyImpreciseStyle,
|
|
DangerouslyImpreciseStyleProp,
|
|
} from 'StyleSheet';
|
|
|
|
function flattenStyle(
|
|
style: ?DangerouslyImpreciseStyleProp,
|
|
): ?DangerouslyImpreciseStyle {
|
|
if (style === null || typeof style !== 'object') {
|
|
return undefined;
|
|
}
|
|
|
|
if (!Array.isArray(style)) {
|
|
return style;
|
|
}
|
|
|
|
var result = {};
|
|
for (var i = 0, styleLength = style.length; i < styleLength; ++i) {
|
|
var computedStyle = flattenStyle(style[i]);
|
|
if (computedStyle) {
|
|
for (var key in computedStyle) {
|
|
result[key] = computedStyle[key];
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
module.exports = flattenStyle;
|