Skip to content

Commit

Permalink
Merge pull request #17 from courseload/skip-null-props
Browse files Browse the repository at this point in the history
Skip processing props that are null or undefined
  • Loading branch information
ryanflorence committed Mar 19, 2015
2 parents 22bdc2d + 026d596 commit e7d1373
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lib/__tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ describe('props', () => {
});
});

it('does not warn if onClick is null', () => {
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
<div onClick={null}/>;
});
});

it('does not warn if onClick is undefined', () => {
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
<div onClick={undefined}/>;
});
});

it('does not warn if there is an aria-label', () => {
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
<div aria-label="foo" onClick={k}/>;
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var assertAccessibility = (tagName, props, children, log) => {

var propTests;
for (var propName in props) {
if (props[propName] === null || props[propName] === undefined) continue;
propTests = assertions.props[propName];
if (propTests)
for (key in propTests)
Expand Down Expand Up @@ -39,4 +40,3 @@ module.exports = (options) => {
return _createElement.apply(this, arguments);
};
};

0 comments on commit e7d1373

Please sign in to comment.