1111 */
1212'use strict' ;
1313
14+ var Platform = require ( 'Platform' ) ;
15+
1416var deepDiffer = require ( 'deepDiffer' ) ;
1517var styleDiffer = require ( 'styleDiffer' ) ;
1618var flattenStyle = require ( 'flattenStyle' ) ;
17- var precomputeStyle = require ( 'precomputeStyle' ) ;
1819
1920type AttributeDiffer = ( prevProp : mixed , nextProp : mixed ) => boolean ;
2021type AttributePreprocessor = ( nextProp : mixed ) => mixed ;
@@ -29,6 +30,21 @@ type AttributeConfiguration =
2930 CustomAttributeConfiguration | AttributeConfiguration /*| boolean*/
3031 ) } ;
3132
33+ function translateKey ( propKey : string ) : string {
34+ if ( propKey === 'transform' ) {
35+ // We currently special case the key for `transform`. iOS uses the
36+ // transformMatrix name and Android uses the decomposedMatrix name.
37+ // TODO: We could unify these names and just use the name `transform`
38+ // all the time. Just need to update the native side.
39+ if ( Platform . OS === 'android' ) {
40+ return 'decomposedMatrix' ;
41+ } else {
42+ return 'transformMatrix' ;
43+ }
44+ }
45+ return propKey ;
46+ }
47+
3248function defaultDiffer ( prevProp : mixed , nextProp : mixed ) : boolean {
3349 if ( typeof nextProp !== 'object' || nextProp === null ) {
3450 // Scalars have already been checked for equality
@@ -55,17 +71,9 @@ function diffNestedProperty(
5571 }
5672
5773 // TODO: Walk both props in parallel instead of flattening.
58- // TODO: Move precomputeStyle to .process for each attribute.
59-
60- var previousFlattenedStyle = precomputeStyle (
61- flattenStyle ( prevProp ) ,
62- validAttributes
63- ) ;
6474
65- var nextFlattenedStyle = precomputeStyle (
66- flattenStyle ( nextProp ) ,
67- validAttributes
68- ) ;
75+ var previousFlattenedStyle = flattenStyle ( prevProp ) ;
76+ var nextFlattenedStyle = flattenStyle ( nextProp ) ;
6977
7078 if ( ! previousFlattenedStyle || ! nextFlattenedStyle ) {
7179 if ( nextFlattenedStyle ) {
@@ -144,7 +152,14 @@ function diffProperties(
144152 if ( ! attributeConfig ) {
145153 continue ; // not a valid native prop
146154 }
147- if ( updatePayload && updatePayload [ propKey ] !== undefined ) {
155+
156+ var altKey = translateKey ( propKey ) ;
157+ if ( ! validAttributes [ altKey ] ) {
158+ // If there is no config for the alternative, bail out. Helps ART.
159+ altKey = propKey ;
160+ }
161+
162+ if ( updatePayload && updatePayload [ altKey ] !== undefined ) {
148163 // If we're in a nested attribute set, we may have set this property
149164 // already. If so, bail out. The previous update is what counts.
150165 continue ;
@@ -172,7 +187,7 @@ function diffProperties(
172187 // case: !Object is the default case
173188 if ( defaultDiffer ( prevProp , nextProp ) ) {
174189 // a normal leaf has changed
175- ( updatePayload || ( updatePayload = { } ) ) [ propKey ] = nextProp ;
190+ ( updatePayload || ( updatePayload = { } ) ) [ altKey ] = nextProp ;
176191 }
177192 } else if ( typeof attributeConfig . diff === 'function' ||
178193 typeof attributeConfig . process === 'function' ) {
@@ -186,7 +201,7 @@ function diffProperties(
186201 var nextValue = typeof attributeConfig . process === 'function' ?
187202 attributeConfig . process ( nextProp ) :
188203 nextProp ;
189- ( updatePayload || ( updatePayload = { } ) ) [ propKey ] = nextValue ;
204+ ( updatePayload || ( updatePayload = { } ) ) [ altKey ] = nextValue ;
190205 }
191206 } else {
192207 // default: fallthrough case when nested properties are defined
@@ -210,6 +225,7 @@ function diffProperties(
210225 if ( ! attributeConfig ) {
211226 continue ; // not a valid native prop
212227 }
228+
213229 prevProp = prevProps [ propKey ] ;
214230 if ( prevProp === undefined ) {
215231 continue ; // was already empty anyway
@@ -218,9 +234,10 @@ function diffProperties(
218234 if ( typeof attributeConfig !== 'object' ||
219235 typeof attributeConfig . diff === 'function' ||
220236 typeof attributeConfig . process === 'function' ) {
237+
221238 // case: CustomAttributeConfiguration | !Object
222239 // Flag the leaf property for removal by sending a sentinel.
223- ( updatePayload || ( updatePayload = { } ) ) [ propKey ] = null ;
240+ ( updatePayload || ( updatePayload = { } ) ) [ translateKey ( propKey ) ] = null ;
224241 } else {
225242 // default:
226243 // This is a nested attribute configuration where all the properties
0 commit comments