Skip to content

Commit

Permalink
Merge pull request react-bootstrap#1269 from jontewks/master
Browse files Browse the repository at this point in the history
[changed] allow PropTypes.node in valueValidation
  • Loading branch information
taion committed Sep 4, 2015
2 parents c4d7f27 + bad277e commit 293d2b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/utils/childrenValueInputValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import { singlePropFrom } from './CustomPropTypes';

const propList = ['children', 'value'];
const typeList = [React.PropTypes.number, React.PropTypes.string];

export default function valueValidation(props, propName, componentName) {
let error = singlePropFrom(propList)(props, propName, componentName);

if (!error) {
const oneOfType = React.PropTypes.oneOfType(typeList);
error = oneOfType(props, propName, componentName);
error = React.PropTypes.node(props, propName, componentName);
}

return error;
}
6 changes: 1 addition & 5 deletions test/ButtonInputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ describe('ButtonInput', () =>{
ReactTestUtils.renderIntoDocument(
<ButtonInput value="button" bsStyle="danger" />
);

console.warn.called.should.be.false;
});

it('throws warning about wrong type for bsStyle=error', function () {
Expand Down Expand Up @@ -72,11 +70,9 @@ describe('ButtonInput', () =>{
assert.notInstanceOf(result, Error);
});

it('does not allow elements for children', function () {
it('allows elements as children', function () {
ReactTestUtils.renderIntoDocument(
<ButtonInput><span>blah</span></ButtonInput>
);

shouldWarn('propType: Invalid');
});
});
6 changes: 6 additions & 0 deletions test/FormControlsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ describe('Form Controls', function () {

result.should.be.instanceOf(Error);
});

it('allows elements as children', function () {
ReactTestUtils.renderIntoDocument(
<FormControls.Static><span>blah</span></FormControls.Static>
);
});
});
});

0 comments on commit 293d2b9

Please sign in to comment.