diff --git a/Libraries/Image/Image.android.js b/Libraries/Image/Image.android.js index dc267f8fa..9e4705e0f 100644 --- a/Libraries/Image/Image.android.js +++ b/Libraries/Image/Image.android.js @@ -15,6 +15,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var NativeModules = require('NativeModules'); var ImageResizeMode = require('ImageResizeMode'); var ImageStylePropTypes = require('ImageStylePropTypes'); +var ViewStylePropTypes = require('ViewStylePropTypes'); var PropTypes = require('ReactPropTypes'); var React = require('React'); var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); @@ -26,6 +27,8 @@ var flattenStyle = require('flattenStyle'); var merge = require('merge'); var requireNativeComponent = require('requireNativeComponent'); var resolveAssetSource = require('resolveAssetSource'); +var Set = require('Set'); +var filterObject = require('fbjs/lib/filterObject'); var { ImageLoader, @@ -63,6 +66,9 @@ var ImageViewAttributes = merge(ReactNativeViewAttributes.UIView, { shouldNotifyLoadEvents: true, }); +var ViewStyleKeys = new Set(Object.keys(ViewStylePropTypes)); +var ImageSpecificStyleKeys = new Set(Object.keys(ImageStylePropTypes).filter(x => !ViewStyleKeys.has(x))); + var Image = React.createClass({ propTypes: { ...View.propTypes, @@ -222,12 +228,15 @@ var Image = React.createClass({ if (nativeProps.children) { // TODO(6033040): Consider implementing this as a separate native component + const containerStyle = filterObject(style, (val, key) => !ImageSpecificStyleKeys.has(key)); + const imageStyle = filterObject(style, (val, key) => ImageSpecificStyleKeys.has(key)); const imageProps = merge(nativeProps, { - style: styles.absoluteImage, + style: [imageStyle, styles.absoluteImage], children: undefined, }); + return ( - + {this.props.children}