Remove sliceChildren (#9109)

This commit is contained in:
Brandon Dail 2017-03-06 00:52:39 -06:00 committed by GitHub
parent ceafdbf0a5
commit 0c1f515faf
3 changed files with 0 additions and 134 deletions

View File

@ -157,13 +157,6 @@ src/isomorphic/children/__tests__/onlyChild-test.js
* should not fail when passed interpolated single child * should not fail when passed interpolated single child
* should return the only child * should return the only child
src/isomorphic/children/__tests__/sliceChildren-test.js
* should render the whole set if start zero is supplied
* should render the remaining set if no end index is supplied
* should exclude everything at or after the end index
* should allow static children to be sliced
* should slice nested children
src/isomorphic/classic/__tests__/ReactContextValidator-test.js src/isomorphic/classic/__tests__/ReactContextValidator-test.js
* should filter out context not in contextTypes * should filter out context not in contextTypes
* should pass next context to lifecycles * should pass next context to lifecycles

View File

@ -1,93 +0,0 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @emails react-core
*/
'use strict';
describe('sliceChildren', () => {
var React;
var sliceChildren;
beforeEach(() => {
React = require('react');
sliceChildren = require('sliceChildren');
});
it('should render the whole set if start zero is supplied', () => {
var fullSet = [
<div key="A" />,
<div key="B" />,
<div key="C" />,
];
var children = sliceChildren(fullSet, 0);
expect(children).toEqual([
<div key=".$A" />,
<div key=".$B" />,
<div key=".$C" />,
]);
});
it('should render the remaining set if no end index is supplied', () => {
var fullSet = [
<div key="A" />,
<div key="B" />,
<div key="C" />,
];
var children = sliceChildren(fullSet, 1);
expect(children).toEqual([
<div key=".$B" />,
<div key=".$C" />,
]);
});
it('should exclude everything at or after the end index', () => {
var fullSet = [
<div key="A" />,
<div key="B" />,
<div key="C" />,
<div key="D" />,
];
var children = sliceChildren(fullSet, 1, 2);
expect(children).toEqual([
<div key=".$B" />,
]);
});
it('should allow static children to be sliced', () => {
var a = <a />;
var b = <b />;
var c = <i />;
var el = <div>{a}{b}{c}</div>;
var children = sliceChildren(el.props.children, 1, 2);
expect(children).toEqual([
<b key=".1" />,
]);
});
it('should slice nested children', () => {
var fullSet = [
<div key="A" />,
[
<div key="B" />,
<div key="C" />,
],
<div key="D" />,
];
var children = sliceChildren(fullSet, 1, 2);
expect(children).toEqual([
<div key=".1:$B" />,
]);
});
});

View File

@ -1,34 +0,0 @@
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule sliceChildren
*/
'use strict';
var ReactChildren = require('ReactChildren');
/**
* Slice children that are typically specified as `props.children`. This version
* of slice children ignores empty child components.
*
* @param {*} children The children set to filter.
* @param {number} start The first zero-based index to include in the subset.
* @param {?number} end The non-inclusive last index of the subset.
* @return {object} mirrored array with mapped children
*/
function sliceChildren(children, start, end) {
if (children == null) {
return children;
}
var array = ReactChildren.toArray(children);
return array.slice(start, end);
}
module.exports = sliceChildren;