Skip to content

Commit

Permalink
Spread attributes to container.
Browse files Browse the repository at this point in the history
This would allow us to pass event listeners and all sort
of things. See gpbl#122.
  • Loading branch information
srph committed Jan 21, 2016
1 parent 3079803 commit 94a4801
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DayPicker.js
Expand Up @@ -437,7 +437,7 @@ export default class DayPicker extends Component {
}

render() {
const { numberOfMonths, locale, style, tabIndex, canChangeMonth } = this.props;
const { numberOfMonths, locale, style, tabIndex, canChangeMonth, ...attributes } = this.props;
const { currentMonth } = this.state;
let className = `DayPicker DayPicker--${locale}`;

Expand All @@ -460,7 +460,8 @@ export default class DayPicker extends Component {
style={ style }
role="widget"
tabIndex={ canChangeMonth && tabIndex }
onKeyDown={ canChangeMonth && ::this.handleKeyDown }>
onKeyDown={ canChangeMonth && ::this.handleKeyDown }
{...attributes}>
{ canChangeMonth && this.renderNavBar() }
{ months }
</div>
Expand Down
18 changes: 18 additions & 0 deletions test/DayPicker.js
Expand Up @@ -65,6 +65,24 @@ describe("DayPicker", () => {
expect(dayPicker.props.tabIndex).to.equal(10);
});

it("should spread the rest of the props to the container", () => {
const focus = sinon.spy();
const blur = sinon.spy();
const dayPicker = TestUtils.renderIntoDocument(<DayPicker
style={{ color: 'red' }}
onFocus={focus}
onBlur={blur} />);
const node = ReactDOM.findDOMNode(dayPicker);

TestUtils.Simulate.focus(node);
expect(focus.calledOnce).to.be.true;

TestUtils.Simulate.blur(node);
expect(blur.calledOnce).to.be.true;

expect(node.style.color).to.equal("red");
});

it("does not contain a interactionEnabled modifier", () => {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(<DayPicker interactionEnabled={false} />);
Expand Down

0 comments on commit 94a4801

Please sign in to comment.