Fix stylesheet registery
Reviewed By: fkgozali Differential Revision: D5685564 fbshipit-source-id: 0946223108041575b16f05abff4a90867c6323f2
This commit is contained in:
parent
2172bb4acb
commit
68664ac106
|
@ -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;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue