From 804c24a33f390166a89276f68772fa64b1510ba8 Mon Sep 17 00:00:00 2001 From: jquense Date: Sat, 28 Feb 2015 12:16:27 -0500 Subject: [PATCH] [added] Support for React 0.13.x re add react to devDeps remove old or depreciated API's Remove getDOMNode classSet, joinClasses, CloneWithProps Fix case on require() typos, and syntax errors update AMD, cjs package def fix tests Removed test dependence on root refs [FIX] Docs, upgrade to react-router --- Gruntfile.js | 3 +- docs/build.js | 16 +++- docs/client.js | 10 ++- docs/server.js | 15 +++- docs/src/NavMain.js | 11 +-- docs/src/ReactPlayground.js | 2 +- docs/src/Root.js | 30 +------- docs/src/Routes.js | 21 +++++ ie8/index.html | 2 +- ie8/package.json | 4 +- package.json | 11 +-- src/Affix.jsx | 4 +- src/AffixMixin.js | 2 +- src/Alert.jsx | 6 +- src/Badge.jsx | 6 +- src/Button.jsx | 8 +- src/ButtonGroup.jsx | 6 +- src/ButtonToolbar.jsx | 6 +- src/Carousel.jsx | 10 +-- src/CarouselItem.jsx | 8 +- src/Col.jsx | 6 +- src/DropdownButton.jsx | 15 ++-- src/DropdownMenu.jsx | 11 ++- src/DropdownStateMixin.js | 2 +- src/FadeMixin.js | 10 ++- src/Glyphicon.jsx | 6 +- src/Grid.jsx | 4 +- src/Input.jsx | 14 ++-- src/Jumbotron.jsx | 4 +- src/Label.jsx | 6 +- src/ListGroup.jsx | 7 +- src/ListGroupItem.jsx | 24 +++--- src/MenuItem.jsx | 6 +- src/Modal.jsx | 15 ++-- src/ModalTrigger.jsx | 6 +- src/Nav.jsx | 17 ++--- src/NavItem.jsx | 6 +- src/Navbar.jsx | 29 ++++--- src/OverlayMixin.js | 20 +---- src/OverlayTrigger.jsx | 8 +- src/PageHeader.jsx | 4 +- src/PageItem.jsx | 6 +- src/Pager.jsx | 9 +-- src/Panel.jsx | 24 +++--- src/PanelGroup.jsx | 10 +-- src/Popover.jsx | 6 +- src/ProgressBar.jsx | 17 ++--- src/Row.jsx | 4 +- src/SplitButton.jsx | 6 +- src/SubNav.jsx | 10 +-- src/TabPane.jsx | 7 +- src/TabbedArea.jsx | 5 +- src/Table.jsx | 5 +- src/Tooltip.jsx | 5 +- src/Well.jsx | 5 +- src/utils/CustomPropTypes.js | 4 +- src/utils/classSet.js | 39 ---------- src/utils/cloneWithProps.js | 143 ----------------------------------- src/utils/joinClasses.js | 40 ---------- test/DropdownButtonSpec.jsx | 2 +- test/DropdownMenuSpec.jsx | 18 +++-- test/FadeMixinSpec.jsx | 1 + test/ListGroupSpec.jsx | 11 ++- test/NavSpec.jsx | 53 ++++++++----- test/NavbarSpec.jsx | 6 +- test/OverlayMixinSpec.jsx | 2 +- test/PagerSpec.jsx | 11 ++- test/SplitButtonSpec.jsx | 2 +- test/TabbedAreaSpec.jsx | 77 ++++++++++++------- tools/amd/bower.json | 3 +- tools/cjs/package.json | 5 +- 71 files changed, 386 insertions(+), 551 deletions(-) create mode 100644 docs/src/Routes.js delete mode 100644 src/utils/classSet.js delete mode 100644 src/utils/cloneWithProps.js delete mode 100644 src/utils/joinClasses.js diff --git a/Gruntfile.js b/Gruntfile.js index 9f8e622e48..bcce4c838f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -136,7 +136,8 @@ module.exports = function (grunt) { almond: "../tools/vendor/almond" }, packages: [ - { name: 'react', location: '../node_modules/react', main: './react' } + { name: 'react', location: '../node_modules/react', main: './react' }, + { name: 'classnames', location: '../node_modules/classnames', main: './index' } ], include: ["almond", "react-bootstrap"], exclude: ["react"], diff --git a/docs/build.js b/docs/build.js index 4252a7c420..dbde01a273 100755 --- a/docs/build.js +++ b/docs/build.js @@ -2,12 +2,22 @@ var fs = require('fs'); var path = require('path'); -var nodejsx = require('node-jsx').install(); + +require('node-jsx').install(); + +var React = require('react'); +var routes = require('./src/Routes'); +var Router = require('react-router'); + var Root = require('./src/Root'); Root.getPages() .forEach(function (fileName) { - var RootHTML = Root.renderToString({initialPath: fileName}); - fs.writeFileSync(path.join(__dirname, fileName), RootHTML); + Router.run(routes, '/' + fileName, function (Handler) { + var RootHTML = React.renderToString(React.createElement(Handler)); + + fs.writeFileSync( + path.join(__dirname, fileName), RootHTML); + }) }); \ No newline at end of file diff --git a/docs/client.js b/docs/client.js index 80ebcd9b4e..733668d326 100644 --- a/docs/client.js +++ b/docs/client.js @@ -1,9 +1,15 @@ 'use strict'; var React = require('react'); -var Root = require('./src/Root'); +var Router = require('react-router'); +var routes = require('./src/Routes'); // For React devtools window.React = React; -React.render(React.createFactory(Root)(window.INITIAL_PROPS), document); +Router.run(routes, Router.RefreshLocation, function (Handler) { + React.render( + React.createElement(Handler, window.INITIAL_PROPS), document); +}) + + diff --git a/docs/server.js b/docs/server.js index 0b55c78101..244e93d0fb 100644 --- a/docs/server.js +++ b/docs/server.js @@ -2,15 +2,19 @@ var express = require('express'); + var development = process.env.NODE_ENV !== 'production'; var app = express(); if (development) { + var React = require('react'); var path = require('path'); var url = require('url'); var browserify = require('connect-browserify'); var nodejsx = require('node-jsx').install(); - var Root = require('./src/Root'); + + var routes = require('./src/Routes'); + var Router = require('react-router'); app = app .get('/assets/bundle.js', browserify('./client', {debug: true, watch: false})) @@ -18,9 +22,14 @@ if (development) { .use('/vendor', express.static(path.join(__dirname, 'vendor'))) .use(function renderApp(req, res) { var fileName = url.parse(req.url).pathname; - var RootHTML = Root.renderToString({initialPath: fileName}); - res.send(RootHTML); + Router.run(routes, req.url, function (Handler) { + var RootHTML = React.renderToString(React.createElement(Handler)); + + res.send(RootHTML); + }) + + }); } else { app = app diff --git a/docs/src/NavMain.js b/docs/src/NavMain.js index 72cb59f400..930064273d 100644 --- a/docs/src/NavMain.js +++ b/docs/src/NavMain.js @@ -1,19 +1,20 @@ 'use strict'; var React = require('react'); -var Router = require('react-router-component'); +var Router = require('react-router'); var Navbar = require('../../lib/Navbar'); var Nav = require('../../lib/Nav'); + var InternalLink = Router.Link; var NAV_LINKS = { 'getting-started': { - link: '/getting-started.html', + link: 'getting-started', title: 'Getting started' }, 'components': { - link: '/components.html', + link: 'components', title: 'Components' } }; @@ -24,7 +25,7 @@ var NavMain = React.createClass({ }, render: function () { - var brand = React Bootstrap; + var brand = React Bootstrap; return ( @@ -40,7 +41,7 @@ var NavMain = React.createClass({ return (
  • - {link.title} + {link.title}
  • ); } diff --git a/docs/src/ReactPlayground.js b/docs/src/ReactPlayground.js index 7ff19f1b02..28ef4fee4e 100644 --- a/docs/src/ReactPlayground.js +++ b/docs/src/ReactPlayground.js @@ -1,5 +1,5 @@ var React = require('react'); -var classSet = require('react/lib/cx'); +var classSet = require('classnames'); var CodeMirror = global.CodeMirror; var JSXTransformer = global.JSXTransformer; var Accordion = require('../../lib/Accordion'); diff --git a/docs/src/Root.js b/docs/src/Root.js index f97bc30768..be1af64df0 100644 --- a/docs/src/Root.js +++ b/docs/src/Root.js @@ -1,30 +1,7 @@ 'use strict'; var React = require('react'); -var Router = require('react-router-component'); - -var HomePage = React.createFactory(require('./HomePage')); -var GettingStartedPage = React.createFactory(require('./GettingStartedPage')); -var ComponentsPage = React.createFactory(require('./ComponentsPage')); -var NotFoundPage = React.createFactory(require('./NotFoundPage')); - -var Locations = Router.Locations; -var Location = Router.Location; -var NotFound = Router.NotFound; - -var PagesHolder = React.createClass({ - render: function () { - return ( - - - - - - - - ); - } -}); +var Router = require('react-router'); var Root = React.createClass({ statics: { @@ -110,9 +87,7 @@ var Root = React.createClass({ - - - +