Skip to content

Commit

Permalink
Skip processing props that are null or undefined
Browse files Browse the repository at this point in the history
Conflicts:
	lib/index.js
  • Loading branch information
AsaAyers committed Mar 19, 2015
1 parent 22bdc2d commit d745f7f
Show file tree
Hide file tree
Showing 2 changed files with 14 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
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var assertAccessibility = (tagName, props, children, log) => {

var propTests;
for (var propName in props) {
// There's no need to check props that are null or undefined.
if (props[propName] === null || props[propName] === undefined) continue;
propTests = assertions.props[propName];
if (propTests)
for (key in propTests)
Expand Down Expand Up @@ -39,4 +41,3 @@ module.exports = (options) => {
return _createElement.apply(this, arguments);
};
};

0 comments on commit d745f7f

Please sign in to comment.