Skip to content

Commit

Permalink
Get rid of transformMatrix/decomposeMatrix special case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Apr 29, 2016
1 parent b8f8360 commit 4bd9cdf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 54 deletions.
2 changes: 0 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ var whiteListNames = [
'InitializeJavaScriptAppEngine',
'InteractionManager',
'JSTimersExecution',
'merge',
'Platform',
'RCTEventEmitter',
'RCTLog',
'TextInputState',
Expand Down
43 changes: 7 additions & 36 deletions src/renderers/native/ReactNative/ReactNativeAttributePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
'use strict';

var Platform = require('Platform');
var ReactNativePropRegistry = require('ReactNativePropRegistry');

var deepDiffer = require('deepDiffer');
Expand Down Expand Up @@ -47,21 +46,6 @@ type NestedNode = Array<NestedNode> | 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
Expand Down Expand Up @@ -326,20 +310,13 @@ function diffProperties(
var attributeConfig : ?(CustomAttributeConfiguration | AttributeConfiguration);
var nextProp;
var prevProp;
var altKey;

for (var propKey in nextProps) {
attributeConfig = validAttributes[propKey];
if (!attributeConfig) {
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];

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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') {
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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 = {};
}
Expand Down
16 changes: 0 additions & 16 deletions src/renderers/native/ReactNative/__mocks__/Platform.js

This file was deleted.

0 comments on commit 4bd9cdf

Please sign in to comment.