diff --git a/README.md b/README.md index 4768ee0..c48a572 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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}); ``` - diff --git a/lib/__tests__/index-test.js b/lib/__tests__/index-test.js index 1c98fa3..49880f3 100644 --- a/lib/__tests__/index-test.js +++ b/lib/__tests__/index-test.js @@ -1,6 +1,6 @@ var React = require('react'); var assert = require('assert'); -require('../index')(); +require('../index')(React); var assertions = require('../assertions'); var k = () => {}; diff --git a/lib/assertions.js b/lib/assertions.js index 9d75695..e3269df 100644 --- a/lib/assertions.js +++ b/lib/assertions.js @@ -1,4 +1,8 @@ -var React = require('react'); +var React; + +exports.setReact = function(R) { + React = R; +}; var INTERACTIVE = { 'button': true, diff --git a/lib/index.js b/lib/index.js index 8ca8432..37b0898 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,3 @@ -var React = require('react'); var assertions = require('./assertions'); var assertAccessibility = (tagName, props, children) => { @@ -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) { diff --git a/package.json b/package.json index 34eced3..7049a27 100644 --- a/package.json +++ b/package.json @@ -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", @@ -50,4 +47,4 @@ "react", "a11y" ] -} \ No newline at end of file +}