mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
RN: Delete mergeFast
from Text
Reviewed By: sahrens, TheSavior Differential Revision: D7899406 fbshipit-source-id: 35fb14c5af3d01404896342a47af9fa280226c7f
This commit is contained in:
parent
6a1b41643a
commit
a1f2076aae
@ -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<TextProps, State> {
|
||||
ellipsizeMode: 'tail',
|
||||
};
|
||||
|
||||
state = mergeFast(Touchable.Mixin.touchableGetInitialState(), {
|
||||
state = {
|
||||
...Touchable.Mixin.touchableGetInitialState(),
|
||||
isHighlighted: false,
|
||||
});
|
||||
};
|
||||
|
||||
viewConfig = viewConfig;
|
||||
|
||||
@ -143,7 +141,7 @@ class Text extends ReactNative.NativeComponent<TextProps, State> {
|
||||
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',
|
||||
}));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
Loading…
x
Reference in New Issue
Block a user