@samitouri / QOS-React / commits / c9e03f0a85

Type ReactMultiChildUpdateTypes (#7589)

As mentioned in https://www.facebook.com/groups/2003630259862046/permalink/2097088000516271/ I'm going to kill this instance of keyMirror and use a plain string instead with a type union. The current type union is unused right now but when I type ReactMultiChild I will use it.

Christopher Chedeau committed Aug 28, 2016 at 10:31 UTC c9e03f0a859180a150d14f61f5e57148a013259e
5 files changed +20 -31
src/renderers/dom/client/__tests__/ReactDOMIDOperations-test.js
+1 -2
@@ -14,7 +14,6 @@
14 describe('ReactDOMIDOperations', function() {
15 var ReactDOMComponentTree = require('ReactDOMComponentTree');
16 var ReactDOMIDOperations = require('ReactDOMIDOperations');
17 - var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
17
18 it('should update innerHTML and preserve whitespace', function() {
19 var stubNode = document.createElement('div');
@@ -25,7 +24,7 @@ describe('ReactDOMIDOperations', function() {
24 ReactDOMIDOperations.dangerouslyProcessChildrenUpdates(
25 stubInstance,
26 [{
28 - type: ReactMultiChildUpdateTypes.SET_MARKUP,
27 + type: 'SET_MARKUP',
28 content: html,
29 fromIndex: null,
30 toIndex: null,
src/renderers/dom/client/utils/DOMChildrenOperations.js
+5 -6
@@ -13,7 +13,6 @@
13
14 var DOMLazyTree = require('DOMLazyTree');
15 var Danger = require('Danger');
16 -var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
16 var ReactDOMComponentTree = require('ReactDOMComponentTree');
17 var ReactInstrumentation = require('ReactInstrumentation');
18
@@ -179,7 +178,7 @@ var DOMChildrenOperations = {
178 for (var k = 0; k < updates.length; k++) {
179 var update = updates[k];
180 switch (update.type) {
182 - case ReactMultiChildUpdateTypes.INSERT_MARKUP:
181 + case 'INSERT_MARKUP':
182 insertLazyTreeChildAt(
183 parentNode,
184 update.content,
@@ -193,7 +192,7 @@ var DOMChildrenOperations = {
192 );
193 }
194 break;
196 - case ReactMultiChildUpdateTypes.MOVE_EXISTING:
195 + case 'MOVE_EXISTING':
196 moveChild(
197 parentNode,
198 update.fromNode,
@@ -207,7 +206,7 @@ var DOMChildrenOperations = {
206 );
207 }
208 break;
210 - case ReactMultiChildUpdateTypes.SET_MARKUP:
209 + case 'SET_MARKUP':
210 setInnerHTML(
211 parentNode,
212 update.content
@@ -220,7 +219,7 @@ var DOMChildrenOperations = {
219 );
220 }
221 break;
223 - case ReactMultiChildUpdateTypes.TEXT_CONTENT:
222 + case 'TEXT_CONTENT':
223 setTextContent(
224 parentNode,
225 update.content
@@ -233,7 +232,7 @@ var DOMChildrenOperations = {
232 );
233 }
234 break;
236 - case ReactMultiChildUpdateTypes.REMOVE_NODE:
235 + case 'REMOVE_NODE':
236 removeChild(parentNode, update.fromNode);
237 if (__DEV__) {
238 ReactInstrumentation.debugTool.onHostOperation(
src/renderers/native/ReactNativeDOMIDOperations.js
+3 -4
@@ -11,7 +11,6 @@
11 'use strict';
12
13 var ReactNativeComponentTree = require('ReactNativeComponentTree');
14 -var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
14 var UIManager = require('UIManager');
15
16 /**
@@ -41,12 +40,12 @@ var dangerouslyProcessChildrenUpdates = function(inst, childrenUpdates) {
40
41 for (var i = 0; i < childrenUpdates.length; i++) {
42 var update = childrenUpdates[i];
44 - if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING) {
43 + if (update.type === 'MOVE_EXISTING') {
44 (moveFromIndices || (moveFromIndices = [])).push(update.fromIndex);
45 (moveToIndices || (moveToIndices = [])).push(update.toIndex);
47 - } else if (update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
46 + } else if (update.type === 'REMOVE_NODE') {
47 (removeAtIndices || (removeAtIndices = [])).push(update.fromIndex);
49 - } else if (update.type === ReactMultiChildUpdateTypes.INSERT_MARKUP) {
48 + } else if (update.type === 'INSERT_MARKUP') {
49 var mountImage = update.content;
50 var tag = mountImage;
51 (addAtIndices || (addAtIndices = [])).push(update.toIndex);
src/renderers/shared/stack/reconciler/ReactMultiChild.js
+5 -6
@@ -14,7 +14,6 @@
14 var ReactComponentEnvironment = require('ReactComponentEnvironment');
15 var ReactInstanceMap = require('ReactInstanceMap');
16 var ReactInstrumentation = require('ReactInstrumentation');
17 -var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
17
18 var ReactCurrentOwner = require('ReactCurrentOwner');
19 var ReactReconciler = require('ReactReconciler');
@@ -34,7 +33,7 @@ var invariant = require('invariant');
33 function makeInsertMarkup(markup, afterNode, toIndex) {
34 // NOTE: Null values reduce hidden classes.
35 return {
37 - type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
36 + type: 'INSERT_MARKUP',
37 content: markup,
38 fromIndex: null,
39 fromNode: null,
@@ -53,7 +52,7 @@ function makeInsertMarkup(markup, afterNode, toIndex) {
52 function makeMove(child, afterNode, toIndex) {
53 // NOTE: Null values reduce hidden classes.
54 return {
56 - type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
55 + type: 'MOVE_EXISTING',
56 content: null,
57 fromIndex: child._mountIndex,
58 fromNode: ReactReconciler.getHostNode(child),
@@ -71,7 +70,7 @@ function makeMove(child, afterNode, toIndex) {
70 function makeRemove(child, node) {
71 // NOTE: Null values reduce hidden classes.
72 return {
74 - type: ReactMultiChildUpdateTypes.REMOVE_NODE,
73 + type: 'REMOVE_NODE',
74 content: null,
75 fromIndex: child._mountIndex,
76 fromNode: node,
@@ -89,7 +88,7 @@ function makeRemove(child, node) {
88 function makeSetMarkup(markup) {
89 // NOTE: Null values reduce hidden classes.
90 return {
92 - type: ReactMultiChildUpdateTypes.SET_MARKUP,
91 + type: 'SET_MARKUP',
92 content: markup,
93 fromIndex: null,
94 fromNode: null,
@@ -107,7 +106,7 @@ function makeSetMarkup(markup) {
106 function makeTextContent(textContent) {
107 // NOTE: Null values reduce hidden classes.
108 return {
110 - type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
109 + type: 'TEXT_CONTENT',
110 content: textContent,
111 fromIndex: null,
112 fromNode: null,
src/renderers/shared/stack/reconciler/ReactMultiChildUpdateTypes.js
+6 -13
@@ -11,22 +11,15 @@
11
12 'use strict';
13
14 -var keyMirror = require('keyMirror');
15 -
14 /**
15 * When a component's children are updated, a series of update configuration
16 * objects are created in order to batch and serialize the required changes.
17 *
18 * Enumerates all the possible types of update configurations.
21 - *
22 - * @internal
19 */
24 -var ReactMultiChildUpdateTypes = keyMirror({
25 - INSERT_MARKUP: null,
26 - MOVE_EXISTING: null,
27 - REMOVE_NODE: null,
28 - SET_MARKUP: null,
29 - TEXT_CONTENT: null,
30 -});
31 -
32 -module.exports = ReactMultiChildUpdateTypes;
20 +export type ReactMultiChildUpdateTypes =
21 + 'INSERT_MARKUP' |
22 + 'MOVE_EXISTING' |
23 + 'REMOVE_NODE' |
24 + 'SET_MARKUP' |
25 + 'TEXT_CONTENT';