Skip to content

Commit

Permalink
Make sure props with the id is passed down, even if no props were passed
Browse files Browse the repository at this point in the history
in
  • Loading branch information
AsaAyers committed Mar 4, 2015
1 parent 5ced60e commit e52b7e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/__tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var React = require('react');
var assert = require('assert');
require('../index')();
var assertions = require('../assertions');
Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ module.exports = (options) => {
var _createElement = React.createElement;
var log = options && options.throw ? error : warn;
React.createElement = function (type, _props, ...children) {
var props = _props || {};
if (typeof type === 'string') {
var props = _props || {};
var failures = assertAccessibility(type, props, children);
if (failures.length) {
// Generate an id if one doesn't exist
Expand All @@ -44,6 +44,7 @@ module.exports = (options) => {
log(props.id, failures[i]);
}
}
return _createElement.apply(this, arguments);
// make sure props with the id is passed down, even if no props were passed in.
return _createElement.apply(this, [type, props].concat(children));
};
};

0 comments on commit e52b7e5

Please sign in to comment.