Skip to content

Commit

Permalink
Merge pull request #24 from courseload/drop-peer-dependency
Browse files Browse the repository at this point in the history
Drop React from peerDependency and rely on passing it in.
  • Loading branch information
kloots committed May 13, 2015
2 parents 803325d + 2170f25 commit 34533d7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
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"
]
}
}

3 comments on commit 34533d7

@Semigradsky
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kloots how about publish new version to npm? 😄

@AsaAyers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project is following semver right? Just a reminder the API changed and isn't totally backward compatible

@kloots
Copy link
Collaborator Author

@kloots kloots commented on 34533d7 May 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Semigradsky aiming to publish a new version this week. I have two more features I want to add before doing so.

@AsaAyers thanks for the reminder.

Please sign in to comment.