Compare commits

...

20 Commits

Author SHA1 Message Date
Paul O’Shannessy
a067fc0fee Changelog, Readme updates for v0.12.1 2014-11-18 09:30:26 +01:00
jeffmo
e9dde65341 Include 0.12.1 starter kit 2014-11-17 23:57:54 -08:00
jeffmo
6a739ccba6 Update jstransform to version 8.2.0 2014-11-17 22:31:27 -08:00
jeffmo
2119a29770 Needed to npm shrinkwrap with --dev 2014-11-17 19:44:09 -08:00
jeffmo
8f3416e6fd v0.12.1 2014-11-17 19:37:24 -08:00
Christopher Chedeau
11527d7fe4 Merge pull request #2543 from spicyj/strip-types-2
Cherry-pick jstransform, strip-types upgrades and re-shrinkwrap
2014-11-16 20:30:19 -08:00
Ben Alpert
d7e3fb36ad Re-shrinkwrap dependencies with new package.json
After running `npm install` with the old shrinkwrap, I ran:

```
rm -rf npm-shrinkwrap.json node_modules/esprima-fb/
npm install
npm install envify@3.0.0
npm shrinkwrap --dev
```

and ended up with this file. (I had to re-install envify because it wants jstransform@'^6.1.0' but was getting the one at the root which is now `8.0.0`. Now it uses its own copy in `node_modules/envify/node_modules/jstransform/`.)
2014-11-16 20:22:21 -08:00
Gabe Levi
361b00e652 Update stripTypes transform to use fixed up jstransform transform
(cherry picked from commit 0d308add09)
2014-11-16 19:53:58 -08:00
Andres Suarez
9f584d607a Remove esprima-fb and use Syntax from jstransform
(cherry picked from commit bf0a857a92)
2014-11-16 19:53:58 -08:00
Zacharias
55a58460d9 Update jstransform version to ^7.0.0
(cherry picked from commit c260c45db3)
2014-11-16 19:53:58 -08:00
Paul O’Shannessy
ed1ca69183 Merge pull request #2463 from fson/render-to-string-docs
Update React.renderToString argument type in docs
2014-11-05 16:15:25 -08:00
Paul O’Shannessy
a47c6d3717 Merge pull request #2434 from Shraymonks/propTypes-docs
Update deprecated propTypes
2014-11-05 16:15:20 -08:00
Paul O’Shannessy
b6af3c8586 Merge pull request #2433 from zpao/fiddle-integration
Bring in jsfiddle integration script, add harmony
2014-10-31 11:23:43 -07:00
Paul O’Shannessy
cf0a22578d Merge pull request #2443 from kruppel/kurt/minor-tip-typo
Fix typo in If/Else JSX doc.
2014-10-31 10:13:11 -07:00
Cheng Lou
9ee824e5de Merge pull request #2418 from spencer48/patch-1
(docs) Added commas to increase readability.
2014-10-29 18:17:25 -07:00
Paul O’Shannessy
a354e65974 Merge pull request #2428 from cody/fixes
React.renderComponent --> React.render
2014-10-29 18:16:58 -07:00
Paul O’Shannessy
0c1191d2bc Merge pull request #2419 from johnheroy/patch-1
Add comma for readability in tutorial.md
2014-10-29 18:16:19 -07:00
Paul O’Shannessy
434b4a275a Add 0.12 starter kit 2014-10-28 11:40:57 -07:00
Christopher Chedeau
d56bc2f219 Change the date and the link url to match the proper roundup 2014-10-28 11:36:03 -07:00
Paul O’Shannessy
3e925822a6 v0.12.0
- update versions in packages, react
- update version in docs
- npm shrinkwrap
2014-10-28 11:23:41 -07:00
26 changed files with 3591 additions and 44 deletions

View File

@@ -1,3 +1,12 @@
## 0.12.1 (November 18, 2014)
### React Tools
* Types transform updated with latest support
* jstransform version updated with improved ES6 transforms
* Explicit Esprima dependency removed in favor of using Esprima information exported by jstransform
## 0.12.0 (October 28, 2014)
### React Core

View File

@@ -35,12 +35,12 @@ The fastest way to get started is to serve JavaScript from the CDN (also availab
```html
<!-- The core React library -->
<script src="http://fb.me/react-0.12.0.js"></script>
<script src="http://fb.me/react-0.12.1.js"></script>
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
<script src="http://fb.me/JSXTransformer-0.12.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.1.js"></script>
```
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.12.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.12.1.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
If you'd like to use [bower](http://bower.io), it's as easy as:

View File

@@ -34,4 +34,4 @@ sass:
sass_dir: _css
gems:
- jekyll-redirect-from
react_version: 0.11.2
react_version: 0.12.1

View File

@@ -0,0 +1,11 @@
(function() {
var tag = document.querySelector(
'script[type="application/javascript;version=1.7"]'
);
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
}
tag.setAttribute('type', 'text/jsx;harmony=true');
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');
})();

View File

@@ -6,7 +6,7 @@ prev: jsx-in-depth.html
next: jsx-gotchas.html
---
If you know all the properties that you want to place on a component a head of time, it is easy to use JSX:
If you know all the properties that you want to place on a component ahead of time, it is easy to use JSX:
```javascript
var component = <Component foo={x} bar={y} />;

View File

@@ -45,9 +45,9 @@ If you'd like to use React on a touch device such as a phone or tablet, simply c
## Under the Hood: Autobinding and Event Delegation
Under the hood React does a few things to keep your code performant and easy to understand.
Under the hood, React does a few things to keep your code performant and easy to understand.
**Autobinding:** When creating callbacks in JavaScript you usually need to explicitly bind a method to its instance such that the value of `this` is correct. With React, every method is automatically bound to its component instance. React caches the bound method such that it's extremely CPU and memory efficient. It's also less typing!
**Autobinding:** When creating callbacks in JavaScript, you usually need to explicitly bind a method to its instance such that the value of `this` is correct. With React, every method is automatically bound to its component instance. React caches the bound method such that it's extremely CPU and memory efficient. It's also less typing!
**Event delegation:** React doesn't actually attach event handlers to the nodes themselves. When React starts up, it starts listening for all events at the top level using a single event listener. When a component is mounted or unmounted, the event handlers are simply added or removed from an internal mapping. When an event occurs, React knows how to dispatch it using this mapping. When there are no event handlers left in the mapping, React's event handlers are simple no-ops. To learn more about why this is fast, see [David Walsh's excellent blog post](http://davidwalsh.name/event-delegate).

View File

@@ -25,12 +25,12 @@ React.createClass({
optionalObject: React.PropTypes.object,
optionalString: React.PropTypes.string,
// Anything that can be rendered: numbers, strings, components or an array
// Anything that can be rendered: numbers, strings, elements or an array
// containing these types.
optionalRenderable: React.PropTypes.renderable,
optionalNode: React.PropTypes.node,
// A React component.
optionalComponent: React.PropTypes.component,
// A React element.
optionalElement: React.PropTypes.element,
// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
@@ -120,13 +120,13 @@ React.render(
## Single Child
With `React.PropTypes.component` you can specify that only a single child can be passed to
With `React.PropTypes.element` you can specify that only a single child can be passed to
a component as children.
```javascript
var MyComponent = React.createClass({
propTypes: {
children: React.PropTypes.component.isRequired
children: React.PropTypes.element.isRequired
},
render: function() {

View File

@@ -37,7 +37,7 @@ var FancyCheckbox = React.createClass({
);
}
});
React.renderComponent(
React.render(
<FancyCheckbox checked={true} onClick={console.log}>
Hello world!
</FancyCheckbox>,
@@ -70,7 +70,7 @@ var FancyCheckbox = React.createClass({
);
}
});
React.renderComponent(
React.render(
<FancyCheckbox checked={true} onClick={console.log}>
Hello world!
</FancyCheckbox>,

View File

@@ -57,10 +57,10 @@ Remove a mounted React component from the DOM and clean up its event handlers an
### React.renderToString
```javascript
string renderToString(ReactComponent component)
string renderToString(ReactElement element)
```
Render a component to its initial HTML. This should only be used on the server. React will return an HTML string. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
Render a ReactElement to its initial HTML. This should only be used on the server. React will return an HTML string. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
If you call `React.render()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.
@@ -68,7 +68,7 @@ If you call `React.render()` on a node that already has this server-rendered mar
### React.renderToStaticMarkup
```javascript
string renderToStaticMarkup(ReactComponent component)
string renderToStaticMarkup(ReactElement element)
```
Similar to `renderToString`, except this doesn't create extra DOM attributes such as `data-react-id`, that React uses internally. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save lots of bytes.

View File

@@ -25,7 +25,7 @@ It'll also have a few neat features:
### Getting started
For this tutorial we'll use prebuilt JavaScript files on a CDN. Open up your favorite editor and create a new HTML document:
For this tutorial, we'll use prebuilt JavaScript files on a CDN. Open up your favorite editor and create a new HTML document:
```html
<!-- template.html -->

Binary file not shown.

Binary file not shown.

View File

@@ -24,7 +24,7 @@ This means that `if` statements don't fit in. Take this example:
<div id={if (condition) { 'msg' }}>Hello World!</div>
// Is transformed to this JS:
React.createElement("dov", {id: if (condition) { 'msg' }}, "Hello World!");
React.createElement("div", {id: if (condition) { 'msg' }}, "Hello World!");
```
That's not valid JS. You probably want to make use of a ternary expression:

View File

@@ -2,6 +2,7 @@
var visitors = require('./vendor/fbtransform/visitors');
var transform = require('jstransform').transform;
var typesSyntax = require('jstransform/visitors/type-syntax');
var Buffer = require('buffer').Buffer;
module.exports = {
@@ -37,7 +38,11 @@ function innerTransform(input, options) {
visitorSets.push('harmony');
}
if (options.stripTypes) {
visitorSets.push('type-annotations');
// Stripping types needs to happen before the other transforms
// unfortunately, due to bad interactions. For example,
// es6-rest-param-visitors conflict with stripping rest param type
// annotation
input = transform(typesSyntax.visitorList, input, options).code;
}
var visitorList = visitors.getVisitorsBySet(visitorSets);

View File

@@ -1,7 +1,7 @@
{
"name": "react",
"description": "React is a JavaScript library for building user interfaces.",
"version": "0.12.0-rc1",
"version": "0.12.1",
"keywords": [
"react"
],

3510
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "react-tools",
"description": "A set of complementary tools to React, including the JSX transformer.",
"version": "0.12.0-rc1",
"version": "0.12.1",
"keywords": [
"react",
"jsx",
@@ -27,8 +27,7 @@
},
"dependencies": {
"commoner": "^0.10.0",
"esprima-fb": "^6001.1.0-dev-harmony-fb",
"jstransform": "^6.3.2"
"jstransform": "^8.2.0"
},
"devDependencies": {
"benchmark": "~1.0.0",

View File

@@ -18,7 +18,7 @@ exports.setup = function(){
number: React.PropTypes.number,
string: React.PropTypes.string.isRequired,
func: React.PropTypes.func.isRequired,
renderable: React.PropTypes.renderable.isRequired,
node: React.PropTypes.node.isRequired,
instanceOf: React.PropTypes.instanceOf(Thing).isRequired
},
render: function() {
@@ -33,14 +33,14 @@ exports.setup = function(){
number: React.PropTypes.number,
string: React.PropTypes.string.isRequired,
func: React.PropTypes.func.isRequired,
renderable: React.PropTypes.renderable.isRequired,
renderable2: React.PropTypes.renderable.isRequired,
node: React.PropTypes.node.isRequired,
node2: React.PropTypes.node.isRequired,
instanceOf: React.PropTypes.instanceOf(Thing).isRequired,
component: React.PropTypes.component.isRequired
element: React.PropTypes.element.isRequired
},
render: function(){
return React.DOM.li(null,
this.props.number + this.props.string + this.props.renderable
this.props.number + this.props.string + this.props.node
);
}
});
@@ -63,10 +63,10 @@ exports.fn = function(){
number: Math.random(),
string: 'banana banana banana',
func: function() { return 'this is a function'; },
renderable: 'renderable string',
renderable2: [MyReactComponent(), 'a string'],
node: 'renderable string',
node2: [MyReactComponent(), 'a string'],
instanceOf: new Thing,
component: MyReactComponent()
element: MyReactComponent()
}));
};

View File

@@ -179,6 +179,6 @@ if (__DEV__) {
// Version exists only in the open-source version of React, not in Facebook's
// internal version.
React.version = '0.12.0-rc1';
React.version = '0.12.1';
module.exports = React;

View File

@@ -13,6 +13,7 @@
var buffer = require('buffer');
var transform = require('jstransform').transform;
var typesSyntax = require('jstransform/visitors/type-syntax');
var visitors = require('./fbtransform/visitors');
var headEl;
@@ -42,6 +43,14 @@ function transformReact(source, options) {
visitorList = visitors.transformVisitors.react;
}
if (options.stripTypes) {
// Stripping types needs to happen before the other transforms
// unfortunately, due to bad interactions. For example,
// es6-rest-param-visitors conflict with stripping rest param type
// annotation
source = transform(typesSyntax.visitorList, source, options).code;
}
return transform(visitorList, source, {
sourceMap: supportsAccessors && options.sourceMap
});
@@ -240,6 +249,9 @@ function loadScripts(scripts) {
if (/;harmony=true(;|$)/.test(script.type)) {
options.harmony = true
}
if (/;stripTypes=true(;|$)/.test(script.type)) {
options.stripTypes = true;
}
// script.async is always true for non-javascript script tags
var async = script.hasAttribute('async');

View File

@@ -4,6 +4,7 @@
"use strict";
var transform = require('jstransform').transform;
var typesSyntax = require('jstransform/visitors/type-syntax');
var visitors = require('./visitors');
/**
@@ -16,6 +17,12 @@ var visitors = require('./visitors');
function transformAll(source, options, excludes) {
excludes = excludes || [];
// Stripping types needs to happen before the other transforms
// unfortunately, due to bad interactions. For example,
// es6-rest-param-visitors conflict with stripping rest param type
// annotation
source = transform(typesSyntax.visitorList, source, options).code;
// The typechecker transform must run in a second pass in order to operate on
// the entire source code -- so exclude it from the first pass
var visitorsList = visitors.getAllVisitors(excludes.concat('typechecker'));

View File

@@ -9,7 +9,7 @@
/*global exports:true*/
"use strict";
var Syntax = require('esprima-fb').Syntax;
var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');
var FALLBACK_TAGS = require('./xjs').knownTags;

View File

@@ -9,7 +9,7 @@
/*global exports:true*/
"use strict";
var Syntax = require('esprima-fb').Syntax;
var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');
function addDisplayName(displayName, object, state) {

View File

@@ -8,7 +8,7 @@
*/
/*global exports:true*/
"use strict";
var Syntax = require('esprima-fb').Syntax;
var Syntax = require('jstransform').Syntax;
var utils = require('jstransform/src/utils');
var knownTags = {

View File

@@ -9,7 +9,6 @@ var es6Templates = require('jstransform/visitors/es6-template-visitors');
var es7SpreadProperty = require('jstransform/visitors/es7-spread-property-visitors');
var react = require('./transforms/react');
var reactDisplayName = require('./transforms/reactDisplayName');
var typesSyntax = require('jstransform/visitors/type-syntax');
/**
* Map from transformName => orderedListOfVisitors.
@@ -23,8 +22,7 @@ var transformVisitors = {
'es6-rest-params': es6RestParameters.visitorList,
'es6-templates': es6Templates.visitorList,
'es7-spread-property': es7SpreadProperty.visitorList,
'react': react.visitorList.concat(reactDisplayName.visitorList),
'types': typesSyntax.visitorList
'react': react.visitorList.concat(reactDisplayName.visitorList)
};
var transformSets = {
@@ -40,9 +38,6 @@ var transformSets = {
],
'react': [
'react'
],
'type-annotations': [
'types'
]
};
@@ -50,7 +45,6 @@ var transformSets = {
* Specifies the order in which each transform should run.
*/
var transformRunOrder = [
'types',
'es6-arrow-functions',
'es6-object-concise-method',
'es6-object-short-notation',