From 4f4017ede08f6ec72d0788ff0654eb2e3b2a2810 Mon Sep 17 00:00:00 2001 From: Jimmy Jia Date: Fri, 16 Oct 2015 22:25:23 -0400 Subject: [PATCH] [fixed] DropdownTitle children v. title Prefer children for label, but default to title otherwise --- src/DropdownToggle.js | 11 ++--------- test/DropdownToggleSpec.js | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/DropdownToggle.js b/src/DropdownToggle.js index 30aceb9803..10fe3d234a 100644 --- a/src/DropdownToggle.js +++ b/src/DropdownToggle.js @@ -1,7 +1,6 @@ import React from 'react'; import classNames from 'classnames'; import Button from './Button'; -import singlePropFrom from 'react-prop-types/lib/singlePropFrom'; import SafeAnchor from './SafeAnchor'; const CARET = ; @@ -23,17 +22,12 @@ export default class DropdownToggle extends React.Component { type="button" aria-haspopup aria-expanded={this.props.open}> - {this.props.title || this.props.children}{caret} + {this.props.children || this.props.title}{caret} ); } } -const titleAndChildrenValidation = singlePropFrom( - 'title', - 'children' -); - DropdownToggle.defaultProps = { open: false, useAnchor: false, @@ -42,10 +36,9 @@ DropdownToggle.defaultProps = { DropdownToggle.propTypes = { bsRole: React.PropTypes.string, - children: titleAndChildrenValidation, noCaret: React.PropTypes.bool, open: React.PropTypes.bool, - title: titleAndChildrenValidation, + title: React.PropTypes.string, useAnchor: React.PropTypes.bool }; diff --git a/test/DropdownToggleSpec.js b/test/DropdownToggleSpec.js index f8ae74e999..cb8ebe20c7 100644 --- a/test/DropdownToggleSpec.js +++ b/test/DropdownToggleSpec.js @@ -27,7 +27,7 @@ describe('DropdownToggle', () => { it('renders title children', () => { const instance = ReactTestUtils.renderIntoDocument( - +

herpa derpa

);