Remove sliceChildren (#9109)
Brandon Dail committed
Mar 6, 2017 at 00:52 UTC
0c1f515fafb61dc6586f8a47fbb4c9db9bc8b0e5
3 files changed
-134
scripts/fiber/tests-passing.txt
-7
@@ -157,13 +157,6 @@ src/isomorphic/children/__tests__/onlyChild-test.js
157
* should not fail when passed interpolated single child
158
* should return the only child
159
160
-src/isomorphic/children/__tests__/sliceChildren-test.js
161
-* should render the whole set if start zero is supplied
162
-* should render the remaining set if no end index is supplied
163
-* should exclude everything at or after the end index
164
-* should allow static children to be sliced
165
-* should slice nested children
166
-
160
src/isomorphic/classic/__tests__/ReactContextValidator-test.js
161
* should filter out context not in contextTypes
162
* should pass next context to lifecycles
src/isomorphic/children/__tests__/sliceChildren-test.js
deleted
-93
@@ -1,93 +0,0 @@
1
-/**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @emails react-core
10
- */
11
-
12
-'use strict';
13
-
14
-describe('sliceChildren', () => {
15
-
16
- var React;
17
-
18
- var sliceChildren;
19
-
20
- beforeEach(() => {
21
- React = require('react');
22
-
23
- sliceChildren = require('sliceChildren');
24
- });
25
-
26
- it('should render the whole set if start zero is supplied', () => {
27
- var fullSet = [
28
- <div key="A" />,
29
- <div key="B" />,
30
- <div key="C" />,
31
- ];
32
- var children = sliceChildren(fullSet, 0);
33
- expect(children).toEqual([
34
- <div key=".$A" />,
35
- <div key=".$B" />,
36
- <div key=".$C" />,
37
- ]);
38
- });
39
-
40
- it('should render the remaining set if no end index is supplied', () => {
41
- var fullSet = [
42
- <div key="A" />,
43
- <div key="B" />,
44
- <div key="C" />,
45
- ];
46
- var children = sliceChildren(fullSet, 1);
47
- expect(children).toEqual([
48
- <div key=".$B" />,
49
- <div key=".$C" />,
50
- ]);
51
- });
52
-
53
- it('should exclude everything at or after the end index', () => {
54
- var fullSet = [
55
- <div key="A" />,
56
- <div key="B" />,
57
- <div key="C" />,
58
- <div key="D" />,
59
- ];
60
- var children = sliceChildren(fullSet, 1, 2);
61
- expect(children).toEqual([
62
- <div key=".$B" />,
63
- ]);
64
- });
65
-
66
- it('should allow static children to be sliced', () => {
67
- var a = <a />;
68
- var b = <b />;
69
- var c = <i />;
70
-
71
- var el = <div>{a}{b}{c}</div>;
72
- var children = sliceChildren(el.props.children, 1, 2);
73
- expect(children).toEqual([
74
- <b key=".1" />,
75
- ]);
76
- });
77
-
78
- it('should slice nested children', () => {
79
- var fullSet = [
80
- <div key="A" />,
81
- [
82
- <div key="B" />,
83
- <div key="C" />,
84
- ],
85
- <div key="D" />,
86
- ];
87
- var children = sliceChildren(fullSet, 1, 2);
88
- expect(children).toEqual([
89
- <div key=".1:$B" />,
90
- ]);
91
- });
92
-
93
-});
src/isomorphic/children/sliceChildren.js
deleted
-34
@@ -1,34 +0,0 @@
1
-/**
2
- * Copyright 2013-present, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule sliceChildren
10
- */
11
-
12
-'use strict';
13
-
14
-var ReactChildren = require('ReactChildren');
15
-
16
-/**
17
- * Slice children that are typically specified as `props.children`. This version
18
- * of slice children ignores empty child components.
19
- *
20
- * @param {*} children The children set to filter.
21
- * @param {number} start The first zero-based index to include in the subset.
22
- * @param {?number} end The non-inclusive last index of the subset.
23
- * @return {object} mirrored array with mapped children
24
- */
25
-function sliceChildren(children, start, end) {
26
- if (children == null) {
27
- return children;
28
- }
29
-
30
- var array = ReactChildren.toArray(children);
31
- return array.slice(start, end);
32
-}
33
-
34
-module.exports = sliceChildren;