Fix stylesheet registery

Reviewed By: fkgozali

Differential Revision: D5685564

fbshipit-source-id: 0946223108041575b16f05abff4a90867c6323f2
This commit is contained in:
Spencer Ahrens 2017-08-23 08:42:54 -07:00 committed by Facebook Github Bot
parent 2172bb4acb
commit 68664ac106
1 changed files with 10 additions and 10 deletions

View File

@ -11,17 +11,17 @@
*/
'use strict';
var PixelRatio = require('PixelRatio');
var ReactNativePropRegistry = require('ReactNativePropRegistry');
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
var StyleSheetValidation = require('StyleSheetValidation');
const PixelRatio = require('PixelRatio');
const ReactNativePropRegistry = require('ReactNativePropRegistry');
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
const StyleSheetValidation = require('StyleSheetValidation');
var flatten = require('flattenStyle');
const flatten = require('flattenStyle');
export type Styles = {[key: string]: Object};
export type StyleSheet<S: Styles> = {[key: $Keys<S>]: number};
var hairlineWidth = PixelRatio.roundToNearestPixel(0.4);
let hairlineWidth = PixelRatio.roundToNearestPixel(0.4);
if (hairlineWidth === 0) {
hairlineWidth = 1 / PixelRatio.get();
}
@ -41,7 +41,7 @@ const absoluteFill = ReactNativePropRegistry.register(absoluteFillObject); // Th
* Create a new StyleSheet:
*
* ```
* var styles = StyleSheet.create({
* const styles = StyleSheet.create({
* container: {
* borderRadius: 4,
* borderWidth: 0.5,
@ -135,7 +135,7 @@ module.exports = {
*
* Example:
* ```
* var styles = StyleSheet.create({
* const styles = StyleSheet.create({
* listItem: {
* flex: 1,
* fontSize: 16,
@ -196,9 +196,9 @@ module.exports = {
*/
create<S: Styles>(obj: S): StyleSheet<S> {
const result: StyleSheet<S> = {};
for (var key in obj) {
for (const key in obj) {
StyleSheetValidation.validateStyle(key, obj);
result[key] = ReactNativePropRegistry.register(obj[key]);
result[key] = obj[key] && ReactNativePropRegistry.register(obj[key]);
}
return result;
},