@samitouri / QOS-React / commits / 94e843955d

Remove experimental support for maps as children

Andrew Clark committed Feb 6, 2017 at 15:30 UTC 94e843955dd4d1d8d9e6267d70681f09f0dfb96c
7 files changed +11 -177
scripts/fiber/tests-failing.txt
-3
@@ -47,8 +47,5 @@ src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js
47 src/renderers/shared/shared/__tests__/ReactComponentLifeCycle-test.js
48 * should carry through each of the phases of setup
49
50 -src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
51 -* should reorder keyed text nodes
52 -
50 src/renderers/shared/shared/__tests__/refs-test.js
51 * Should increase refs with an increase in divs
scripts/fiber/tests-passing-except-dev.txt
-3
@@ -111,8 +111,5 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
111 * should warn about `setState` in getChildContext
112 * should disallow nested render calls
113
114 -src/renderers/shared/shared/__tests__/ReactMultiChild-test.js
115 -* should warn for using maps as children with owner info
116 -
114 src/renderers/shared/shared/__tests__/ReactStatelessComponent-test.js
115 * should warn for childContextTypes on a functional component
scripts/fiber/tests-passing.txt
-1
@@ -124,7 +124,6 @@ src/isomorphic/children/__tests__/ReactChildren-test.js
124 * should retain key across two mappings
125 * should be called for each child in an iterable without keys
126 * should be called for each child in an iterable with keys
127 -* should use keys from entry iterables
127 * should not enumerate enumerable numbers (#4776)
128 * should allow extension of native prototypes
129 * should pass key to returned component
src/isomorphic/children/__tests__/ReactChildren-test.js
+1 -63
@@ -105,7 +105,7 @@ describe('ReactChildren', () => {
105 expect(callback).toHaveBeenCalledWith(one, 1);
106 expect(callback).toHaveBeenCalledWith(two, 2);
107 expect(callback).toHaveBeenCalledWith(three, 3);
108 - expect(callback).toHaveBeenCalledWith(four, 4);
108 + expect(callback).toHaveBeenCalledWith(four, 4);
109 callback.calls.reset();
110 }
111
@@ -365,68 +365,6 @@ describe('ReactChildren', () => {
365 ]);
366 });
367
368 - it('should use keys from entry iterables', () => {
369 - spyOn(console, 'error');
370 -
371 - var threeDivEntryIterable = {
372 - '@@iterator': function() {
373 - var i = 0;
374 - return {
375 - next: function() {
376 - if (i++ < 3) {
377 - return {value: ['#' + i, <div />], done: false};
378 - } else {
379 - return {value: undefined, done: true};
380 - }
381 - },
382 - };
383 - },
384 - };
385 - threeDivEntryIterable.entries = threeDivEntryIterable['@@iterator'];
386 -
387 - var context = {};
388 - var callback =
389 - jasmine.createSpy().and.callFake(function(kid) {
390 - expect(this).toBe(context);
391 - return kid;
392 - });
393 -
394 - var instance = (
395 - <div>
396 - {threeDivEntryIterable}
397 - </div>
398 - );
399 -
400 - function assertCalls() {
401 - expect(callback.calls.count()).toBe(3);
402 - // TODO: why
403 - expect(callback).toHaveBeenCalledWith(<div />, 0);
404 - expect(callback).toHaveBeenCalledWith(<div />, 1);
405 - expect(callback).toHaveBeenCalledWith(<div />, 2);
406 -
407 - callback.calls.reset();
408 - }
409 -
410 - React.Children.forEach(instance.props.children, callback, context);
411 - assertCalls();
412 - expectDev(console.error.calls.count()).toBe(1);
413 - expectDev(console.error.calls.argsFor(0)[0]).toContain(
414 - 'Warning: Using Maps as children is not yet fully supported. It is an ' +
415 - 'experimental feature that might be removed. Convert it to a sequence ' +
416 - '/ iterable of keyed ReactElements instead.'
417 - );
418 - console.error.calls.reset();
419 -
420 - var mappedChildren = React.Children.map(instance.props.children, callback, context);
421 - assertCalls();
422 - expect(mappedChildren).toEqual([
423 - <div key=".$#1:0" />,
424 - <div key=".$#2:0" />,
425 - <div key=".$#3:0" />,
426 - ]);
427 - expectDev(console.error.calls.count()).toBe(0);
428 - });
429 -
368 it('should not enumerate enumerable numbers (#4776)', () => {
369 /*eslint-disable no-extend-native */
370 Number.prototype['@@iterator'] = function() {
src/renderers/shared/shared/__tests__/ReactMultiChild-test.js
-22
@@ -261,28 +261,6 @@ describe('ReactMultiChild', () => {
261 ' in Parent (at **)'
262 );
263 });
264 -
265 - it('should warn for using maps as children with owner info', () => {
266 - spyOn(console, 'error');
267 -
268 - class Parent extends React.Component {
269 - render() {
270 - return (
271 - <div>{new Map([['foo', 0], ['bar', 1]])}</div>
272 - );
273 - }
274 - }
275 -
276 - var container = document.createElement('div');
277 - ReactDOM.render(<Parent />, container);
278 -
279 - expectDev(console.error.calls.count()).toBe(1);
280 - expectDev(console.error.calls.argsFor(0)[0]).toBe(
281 - 'Warning: Using Maps as children is not yet fully supported. It is an ' +
282 - 'experimental feature that might be removed. Convert it to a sequence ' +
283 - '/ iterable of keyed ReactElements instead.\n\nCheck the render method of `Parent`.'
284 - );
285 - });
264 });
265
266 it('should reorder bailed-out children', () => {
src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
-34
@@ -220,38 +220,4 @@ describe('ReactMultiChildText', () => {
220 ReactTestUtils.renderIntoDocument(<div><h1>{['A', 'B']}</h1></div>);
221 }).not.toThrow();
222 });
223 -
224 - it('should reorder keyed text nodes', () => {
225 - spyOn(console, 'error');
226 -
227 - var container = document.createElement('div');
228 - ReactDOM.render(
229 - <div>{new Map([['a', 'alpha'], ['b', 'beta']])}</div>,
230 - container
231 - );
232 -
233 - var childNodes = container.firstChild.childNodes;
234 - var alpha1 = childNodes[0];
235 - var alpha2 = childNodes[1];
236 - var alpha3 = childNodes[2];
237 - var beta1 = childNodes[3];
238 - var beta2 = childNodes[4];
239 - var beta3 = childNodes[5];
240 -
241 - ReactDOM.render(
242 - <div>{new Map([['b', 'beta'], ['a', 'alpha']])}</div>,
243 - container
244 - );
245 -
246 - childNodes = container.firstChild.childNodes;
247 - expect(childNodes[0]).toBe(beta1);
248 - expect(childNodes[1]).toBe(beta2);
249 - expect(childNodes[2]).toBe(beta3);
250 - expect(childNodes[3]).toBe(alpha1);
251 - expect(childNodes[4]).toBe(alpha2);
252 - expect(childNodes[5]).toBe(alpha3);
253 -
254 - // Using Maps as children gives a single warning
255 - expectDev(console.error.calls.count()).toBe(1);
256 - });
223 });
src/shared/utils/traverseAllChildren.js
+10 -51
@@ -17,7 +17,6 @@ var REACT_ELEMENT_TYPE = require('ReactElementSymbol');
17 var getIteratorFn = require('getIteratorFn');
18 var invariant = require('invariant');
19 var KeyEscapeUtils = require('KeyEscapeUtils');
20 -var warning = require('warning');
20
21 var SEPARATOR = '.';
22 var SUBSEPARATOR = ':';
@@ -33,8 +32,6 @@ var SUBSEPARATOR = ':';
32 * pattern.
33 */
34
36 -var didWarnAboutMaps = false;
37 -
35 /**
36 * Generate a key string that identifies a component within a set.
37 *
@@ -111,54 +108,16 @@ function traverseAllChildrenImpl(
108 if (iteratorFn) {
109 var iterator = iteratorFn.call(children);
110 var step;
114 - if (iteratorFn !== children.entries) {
115 - var ii = 0;
116 - while (!(step = iterator.next()).done) {
117 - child = step.value;
118 - nextName = nextNamePrefix + getComponentKey(child, ii++);
119 - subtreeCount += traverseAllChildrenImpl(
120 - child,
121 - nextName,
122 - callback,
123 - traverseContext
124 - );
125 - }
126 - } else {
127 - if (__DEV__) {
128 - var mapsAsChildrenAddendum = '';
129 - if (ReactCurrentOwner.current) {
130 - var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
131 - if (mapsAsChildrenOwnerName) {
132 - mapsAsChildrenAddendum = '\n\nCheck the render method of `' + mapsAsChildrenOwnerName + '`.';
133 - }
134 - }
135 - warning(
136 - didWarnAboutMaps,
137 - 'Using Maps as children is not yet fully supported. It is an ' +
138 - 'experimental feature that might be removed. Convert it to a ' +
139 - 'sequence / iterable of keyed ReactElements instead.%s',
140 - mapsAsChildrenAddendum
141 - );
142 - didWarnAboutMaps = true;
143 - }
144 - // Iterator will provide entry [k,v] tuples rather than values.
145 - while (!(step = iterator.next()).done) {
146 - var entry = step.value;
147 - if (entry) {
148 - child = entry[1];
149 - nextName = (
150 - nextNamePrefix +
151 - KeyEscapeUtils.escape(entry[0]) + SUBSEPARATOR +
152 - getComponentKey(child, 0)
153 - );
154 - subtreeCount += traverseAllChildrenImpl(
155 - child,
156 - nextName,
157 - callback,
158 - traverseContext
159 - );
160 - }
161 - }
111 + var ii = 0;
112 + while (!(step = iterator.next()).done) {
113 + child = step.value;
114 + nextName = nextNamePrefix + getComponentKey(child, ii++);
115 + subtreeCount += traverseAllChildrenImpl(
116 + child,
117 + nextName,
118 + callback,
119 + traverseContext
120 + );
121 }
122 } else if (type === 'object') {
123 var addendum = '';