From 0008beb1fb0c197ac117ddee32a5dd0e363b062a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Fri, 29 Apr 2016 15:57:12 -0700 Subject: [PATCH] Get rid of transformMatrix/decomposeMatrix special case (#6660) This is no longer needed on the native side. This is also the last use of the Platform flag. React Core is now platform agnostic with regard to React Native. So I'll remove the mocks and dependency. (cherry picked from commit 0e4b04663422d217f5a796936435603037b08bb5) --- gulpfile.js | 3 -- .../ReactNativeAttributePayload.js | 43 +++---------------- .../__mocks__/InteractionManager.js | 16 ------- .../native/ReactNative/__mocks__/Platform.js | 16 ------- 4 files changed, 7 insertions(+), 71 deletions(-) delete mode 100644 src/renderers/native/ReactNative/__mocks__/InteractionManager.js delete mode 100644 src/renderers/native/ReactNative/__mocks__/Platform.js diff --git a/gulpfile.js b/gulpfile.js index 2c2a7c98239ee..a51a094367e1a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -39,10 +39,7 @@ var whiteListNames = [ 'deepFreezeAndThrowOnMutationInDev', 'flattenStyle', 'InitializeJavaScriptAppEngine', - 'InteractionManager', 'JSTimersExecution', - 'merge', - 'Platform', 'RCTEventEmitter', 'RCTLog', 'TextInputState', diff --git a/src/renderers/native/ReactNative/ReactNativeAttributePayload.js b/src/renderers/native/ReactNative/ReactNativeAttributePayload.js index ca1cd57030408..a2976c6025066 100644 --- a/src/renderers/native/ReactNative/ReactNativeAttributePayload.js +++ b/src/renderers/native/ReactNative/ReactNativeAttributePayload.js @@ -11,7 +11,6 @@ */ 'use strict'; -var Platform = require('Platform'); var ReactNativePropRegistry = require('ReactNativePropRegistry'); var deepDiffer = require('deepDiffer'); @@ -47,21 +46,6 @@ type NestedNode = Array | Object | number; var removedKeys = null; var removedKeyCount = 0; -function translateKey(propKey: string) : string { - if (propKey === 'transform') { - // We currently special case the key for `transform`. iOS uses the - // transformMatrix name and Android uses the decomposedMatrix name. - // TODO: We could unify these names and just use the name `transform` - // all the time. Just need to update the native side. - if (Platform.OS === 'android') { - return 'decomposedMatrix'; - } else { - return 'transformMatrix'; - } - } - return propKey; -} - function defaultDiffer(prevProp: mixed, nextProp: mixed) : boolean { if (typeof nextProp !== 'object' || nextProp === null) { // Scalars have already been checked for equality @@ -326,7 +310,6 @@ function diffProperties( var attributeConfig : ?(CustomAttributeConfiguration | AttributeConfiguration); var nextProp; var prevProp; - var altKey; for (var propKey in nextProps) { attributeConfig = validAttributes[propKey]; @@ -334,12 +317,6 @@ function diffProperties( continue; // not a valid native prop } - altKey = translateKey(propKey); - if (!validAttributes[altKey]) { - // If there is no config for the alternative, bail out. Helps ART. - altKey = propKey; - } - prevProp = prevProps[propKey]; nextProp = nextProps[propKey]; @@ -367,7 +344,7 @@ function diffProperties( removedKeys[propKey] = false; } - if (updatePayload && updatePayload[altKey] !== undefined) { + if (updatePayload && updatePayload[propKey] !== undefined) { // Something else already triggered an update to this key because another // value diffed. Since we're now later in the nested arrays our value is // more important so we need to calculate it and override the existing @@ -376,14 +353,14 @@ function diffProperties( // Pattern match on: attributeConfig if (typeof attributeConfig !== 'object') { // case: !Object is the default case - updatePayload[altKey] = nextProp; + updatePayload[propKey] = nextProp; } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { // case: CustomAttributeConfiguration var nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; - updatePayload[altKey] = nextValue; + updatePayload[propKey] = nextValue; } continue; } @@ -397,7 +374,7 @@ function diffProperties( // case: !Object is the default case if (defaultDiffer(prevProp, nextProp)) { // a normal leaf has changed - (updatePayload || (updatePayload = {}))[altKey] = nextProp; + (updatePayload || (updatePayload = {}))[propKey] = nextProp; } } else if (typeof attributeConfig.diff === 'function' || typeof attributeConfig.process === 'function') { @@ -411,7 +388,7 @@ function diffProperties( nextValue = typeof attributeConfig.process === 'function' ? attributeConfig.process(nextProp) : nextProp; - (updatePayload || (updatePayload = {}))[altKey] = nextValue; + (updatePayload || (updatePayload = {}))[propKey] = nextValue; } } else { // default: fallthrough case when nested properties are defined @@ -446,13 +423,7 @@ function diffProperties( continue; // not a valid native prop } - altKey = translateKey(propKey); - if (!attributeConfig[altKey]) { - // If there is no config for the alternative, bail out. Helps ART. - altKey = propKey; - } - - if (updatePayload && updatePayload[altKey] !== undefined) { + if (updatePayload && updatePayload[propKey] !== undefined) { // This was already updated to a diff result earlier. continue; } @@ -468,7 +439,7 @@ function diffProperties( // case: CustomAttributeConfiguration | !Object // Flag the leaf property for removal by sending a sentinel. - (updatePayload || (updatePayload = {}))[altKey] = null; + (updatePayload || (updatePayload = {}))[propKey] = null; if (!removedKeys) { removedKeys = {}; } diff --git a/src/renderers/native/ReactNative/__mocks__/InteractionManager.js b/src/renderers/native/ReactNative/__mocks__/InteractionManager.js deleted file mode 100644 index de72e164a6cf9..0000000000000 --- a/src/renderers/native/ReactNative/__mocks__/InteractionManager.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -// TODO: Figure out a way to drop this dependency - -var InteractionManager = {}; - -module.exports = InteractionManager; diff --git a/src/renderers/native/ReactNative/__mocks__/Platform.js b/src/renderers/native/ReactNative/__mocks__/Platform.js deleted file mode 100644 index fc04c24549a48..0000000000000 --- a/src/renderers/native/ReactNative/__mocks__/Platform.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright 2013-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -'use strict'; - -// Mock of the Native Hooks - -var Platform = {}; - -module.exports = Platform;