Skip to content

Commit

Permalink
Implement React 0.14 Compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
lelandrichardson committed Nov 8, 2015
1 parent a5dc32c commit 1abcf93
Show file tree
Hide file tree
Showing 22 changed files with 567 additions and 397 deletions.
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "airbnb",
"env": {
"node": true,
"mocha": true
},
"rules": {
"id-length": 0,
"new-cap": 0,
"no-console": 0
}
}
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: node_js
sudo: false
node_js:
- "0.10"
- "0.12"
- "iojs"
- "4"
script: "npm run travis"
after_script: "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
env:
- REACT=0.13
- REACT=0.14
before_script: "npm install -g npm@2; sh install-relevant-react.sh"
Empty file added CHANGELOG.md
Empty file.
Empty file added CONTRIBUTING.md
Empty file.
14 changes: 14 additions & 0 deletions install-relevant-react.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

REACT=${REACT:-0.14}

echo "installing React $REACT"

if [ "$REACT" = "0.13" ]; then
npm remove react react-dom react-addons-test-utils react-addons-create-fragment
npm install react@0.13
exit
fi

npm prune
npm install
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
"scripts": {
"prepublish": "npm run build",
"build": "babel src --out-dir build && npm run docs",
"test": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js --watch",
"docs": "doxx --source src --target docs --theme cayman --ignore __tests__,Debug.js,MountedTraversal.js,ShallowTraversal.js,Utils.js --title Catalyst"
"test": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js",
"test-watch": "mocha --compilers js:babel/register --recursive src/**/__tests__/*.js --watch",
"docs": "doxx --source src --target docs --theme cayman --ignore __tests__,Debug.js,MountedTraversal.js,ShallowTraversal.js,Utils.js --title Catalyst",
"lint": "eslint src/**"
},
"repository": {
"type": "git",
Expand All @@ -31,12 +33,17 @@
},
"devDependencies": {
"babel": "^5.8.21",
"babel-eslint": "^4.1.4",
"chai": "^3.2.0",
"coveralls": "^2.11.4",
"doxx": "^2.1.1",
"eslint": "^1.9.0",
"eslint-config-airbnb": "^0.1.0",
"eslint-plugin-react": "^3.8.0",
"mocha": "^2.2.5"
},
"peerDependencies": {
"react": "0.13.x"
"react": "0.13.x || 0.14.x"
},
"optionalDependencies": {
"jsdom": "^6.1.0",
Expand Down
33 changes: 17 additions & 16 deletions src/Debug.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {
childrenOfNode,
} from './ShallowTraversal';
import { without, range, escape, compact } from 'underscore';

import {
propsOfNode,
} from './Utils';
import { without, escape, compact } from 'underscore';

export function typeName(node) {
return typeof node.type === 'function'
Expand All @@ -11,32 +13,31 @@ export function typeName(node) {
}

export function spaces(n) {
return Array(n+1).join(' ');
return Array(n + 1).join(' ');
}

export function indent(depth, string) {
return string.split('\n').map(x => `${spaces(depth)}${x}`).join('\n');
}


function propString(prop) {
switch (typeof prop) {
case 'function':
return '{[Function]}';
case 'string':
return `"${prop}"`;
case 'number':
case 'boolean':
return `{${prop}}`;
case 'object':
return `{{...}}`;
default:
return `{[${typeof prop}]}`;
case 'function':
return '{[Function]}';
case 'string':
return `"${prop}"`;
case 'number':
case 'boolean':
return `{${prop}}`;
case 'object':
return `{{...}}`;
default:
return `{[${typeof prop}]}`;
}
}

function propsString(node) {
const props = node && node._store && node._store.props || {};
const props = propsOfNode(node);
const keys = without(Object.keys(props), 'children');
return keys.map(key => `${key}=${propString(props[key])}`).join(' ');
}
Expand Down
Loading

0 comments on commit 1abcf93

Please sign in to comment.