Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ getting warnings in the console as your app renders.

```js
var a11y = require('react-a11y');
if (ENV === 'development') a11y();
if (ENV === 'development') a11y(React);
```

You probably don't want to call it if you're in production, and better
Expand All @@ -32,6 +32,5 @@ yet, alias the module to nothing with webpack in production.
If you want it to throw errors instead of just warnings:

```
a11y({throw: true});
a11y(React, {throw: true});
```

2 changes: 1 addition & 1 deletion lib/__tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var React = require('react');
var assert = require('assert');
require('../index')();
require('../index')(React);
var assertions = require('../assertions');

var k = () => {};
Expand Down
6 changes: 5 additions & 1 deletion lib/assertions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
var React = require('react');
var React;

exports.setReact = function(R) {
React = R;
};

var INTERACTIVE = {
'button': true,
Expand Down
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var React = require('react');
var assertions = require('./assertions');

var assertAccessibility = (tagName, props, children) => {
Expand Down Expand Up @@ -30,7 +29,12 @@ var warn = (id, msg) => {
};

var nextId = 0;
module.exports = (options) => {
module.exports = (React, options) => {
if (!React && !React.createElement) {
throw new Error('Missing parameter: React');
}
assertions.setReact(React);

var _createElement = React.createElement;
var log = options && options.throw ? error : warn;
React.createElement = function (type, _props, ...children) {
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@
"karma-sourcemap-loader": "^0.3.2",
"karma-webpack": "^1.3.1",
"mocha": "^2.0.1",
"react": "0.12.x",
"react": "^0.12 || ^0.13",
"rf-release": "0.4.0",
"webpack": "^1.4.13"
},
"peerDependencies": {
"react": "^0.12 || ^0.13"
},
"tags": [
"accessibility",
"react",
Expand All @@ -50,4 +47,4 @@
"react",
"a11y"
]
}
}