diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index d983638ac..1727e8f26 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -18,27 +18,24 @@ const Touchable = require('Touchable'); const UIManager = require('UIManager'); const createReactNativeComponentClass = require('createReactNativeComponentClass'); -const mergeFast = require('mergeFast'); const processColor = require('processColor'); import type {PressEvent} from 'CoreEventTypes'; -import type {TextProps} from 'TextProps'; +import type {PressRetentionOffset, TextProps} from 'TextProps'; -type State = { +type State = {| + touchable: {| + touchState: ?string, + responderID: ?number, + |}, isHighlighted: boolean, -}; - -type RectOffset = { - top: number, - left: number, - right: number, - bottom: number, -}; +|}; const PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; const viewConfig = { - validAttributes: mergeFast(ReactNativeViewAttributes.UIView, { + validAttributes: { + ...ReactNativeViewAttributes.UIView, isHighlighted: true, numberOfLines: true, ellipsizeMode: true, @@ -49,7 +46,7 @@ const viewConfig = { adjustsFontSizeToFit: true, minimumFontScale: true, textBreakStrategy: true, - }), + }, uiViewClassName: 'RCTText', }; @@ -67,9 +64,10 @@ class Text extends ReactNative.NativeComponent { ellipsizeMode: 'tail', }; - state = mergeFast(Touchable.Mixin.touchableGetInitialState(), { + state = { + ...Touchable.Mixin.touchableGetInitialState(), isHighlighted: false, - }); + }; viewConfig = viewConfig; @@ -143,7 +141,7 @@ class Text extends ReactNative.NativeComponent { this.props.onLongPress && this.props.onLongPress(e); }; - this.touchableGetPressRectOffset = function(): RectOffset { + this.touchableGetPressRectOffset = function(): PressRetentionOffset { return this.props.pressRetentionOffset || PRESS_RECT_OFFSET; }; } @@ -230,9 +228,10 @@ var RCTVirtualText = RCTText; if (UIManager.RCTVirtualText) { RCTVirtualText = createReactNativeComponentClass('RCTVirtualText', () => ({ - validAttributes: mergeFast(ReactNativeViewAttributes.UIView, { + validAttributes: { + ...ReactNativeViewAttributes.UIView, isHighlighted: true, - }), + }, uiViewClassName: 'RCTVirtualText', })); } diff --git a/Libraries/Text/TextProps.js b/Libraries/Text/TextProps.js index 56229632a..474c8fef8 100644 --- a/Libraries/Text/TextProps.js +++ b/Libraries/Text/TextProps.js @@ -17,12 +17,12 @@ import type {Node} from 'react'; import type {LayoutEvent, PressEvent} from 'CoreEventTypes'; import type {DangerouslyImpreciseStyleProp} from 'StyleSheet'; -type PressRetentionOffset = { +export type PressRetentionOffset = $ReadOnly<{| top: number, left: number, bottom: number, right: number, -}; +|}>; /** * @see https://facebook.github.io/react-native/docs/text.html#reference diff --git a/Libraries/Utilities/mergeFast.js b/Libraries/Utilities/mergeFast.js deleted file mode 100644 index 42e357e5d..000000000 --- a/Libraries/Utilities/mergeFast.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - * - * @flow - */ -'use strict'; - -/** - * Faster version of `merge` that doesn't check its arguments and - * also merges prototype inherited properties. - * - * @param {object} one Any non-null object. - * @param {object} two Any non-null object. - * @return {object} Merging of two objects, including prototype - * inherited properties. - */ -var mergeFast = function(one: Object, two: Object): Object { - var ret = {}; - for (var keyOne in one) { - ret[keyOne] = one[keyOne]; - } - for (var keyTwo in two) { - ret[keyTwo] = two[keyTwo]; - } - return ret; -}; - -module.exports = mergeFast;