Skip to content

Commit e7d1373

Browse files
committed
Merge pull request #17 from courseload/skip-null-props
Skip processing props that are null or undefined
2 parents 22bdc2d + 026d596 commit e7d1373

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/__tests__/index-test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ describe('props', () => {
3535
});
3636
});
3737

38+
it('does not warn if onClick is null', () => {
39+
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
40+
<div onClick={null}/>;
41+
});
42+
});
43+
44+
it('does not warn if onClick is undefined', () => {
45+
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
46+
<div onClick={undefined}/>;
47+
});
48+
});
49+
3850
it('does not warn if there is an aria-label', () => {
3951
doNotExpectWarning(assertions.props.onClick.NO_LABEL.msg, () => {
4052
<div aria-label="foo" onClick={k}/>;

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var assertAccessibility = (tagName, props, children, log) => {
1111

1212
var propTests;
1313
for (var propName in props) {
14+
if (props[propName] === null || props[propName] === undefined) continue;
1415
propTests = assertions.props[propName];
1516
if (propTests)
1617
for (key in propTests)
@@ -39,4 +40,3 @@ module.exports = (options) => {
3940
return _createElement.apply(this, arguments);
4041
};
4142
};
42-

0 commit comments

Comments
 (0)