Skip to content

Commit

Permalink
[fixed] Don't forward own props from <Position>
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Nov 29, 2015
1 parent 9da2860 commit c0b5890
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Position.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class Position extends React.Component {
const {children, className, ...props} = this.props;
const {positionLeft, positionTop, ...arrowPosition} = this.state;

Object.keys(Position.propTypes).forEach(key => delete props[key]);

const child = React.Children.only(children);
return cloneElement(
child,
Expand Down
17 changes: 17 additions & 0 deletions test/PositionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,22 @@ describe('Position', function () {
});
});

it('should not forward own props to child', function () {
let spiedProps;
const Child = (props) => {
spiedProps = props;
return <div />;
};

ReactTestUtils.renderIntoDocument(
<Position target={() => null} childProp="foo">
<Child />
</Position>
);

expect(spiedProps.target).to.not.exist;
expect(spiedProps.childProp).to.equal('foo');
});

// ToDo: add remaining tests
});

0 comments on commit c0b5890

Please sign in to comment.