Skip to content

Commit 90bb980

Browse files
grahamcrackerzpao
authored andcommitted
update docs and test examples for changes in 0.12
(cherry picked from commit 4e81aff) Conflicts: README.md test/dummy/app/assets/javascripts/components/Todo.js.jsx.coffee test/dummy/app/assets/javascripts/components/TodoList.js.jsx test/dummy/app/assets/javascripts/example3.js.jsx test/helper_files/TodoListWithUpdates.js.jsx test/jsxtransform_test.rb test/react_renderer_test.rb
1 parent 25b9897 commit 90bb980

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Alternatively, you can include it directly as a separate script tag:
4646

4747
### JSX
4848

49-
To transform your JSX into JS, simply create `.js.jsx` files, and ensure that the file has the `/** @jsx React.DOM */` docblock. These files will be transformed on request, or precompiled as part of the `assets:precompile` task.
49+
To transform your JSX into JS, simply create `.js.jsx` files. These files will be transformed on request, or precompiled as part of the `assets:precompile` task.
5050

5151

5252
## Configuring
@@ -83,8 +83,6 @@ end
8383
It is possible to use JSX with CoffeeScript. The caveat is that you will still need to include the docblock. Since CoffeeScript doesn't allow `/* */` style comments, we need to do something a little different. We also need to embed JSX inside backticks so CoffeeScript ignores the syntax it doesn't understand. Here's an example:
8484

8585
```coffee
86-
###* @jsx React.DOM ###
87-
8886
Component = React.createClass
8987
render: ->
9088
`<ExampleComponent videos={this.props.videos} />`
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/** @jsx React.DOM */
21
<div/>;
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
###* @jsx React.DOM ###
2-
31
Component = React.createClass
42
render: ->
53
`<ExampleComponent videos={this.props.videos} />`

test/jsxtransform_test.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22

33
# The transformer is inserting a newline after the docblock for some reason...
44
EXPECTED_JS = <<eos
5-
/** @jsx React.DOM */
6-
7-
React.DOM.div(null);
5+
React.createElement("div", null);
86
eos
97

108
EXPECTED_JS_2 = <<eos
11-
/** @jsx React.DOM*/
12-
13-
149
(function() {
1510
var Component;
1611
1712
Component = React.createClass({displayName: 'Component',
1813
render: function() {
19-
return ExampleComponent( {videos:this.props.videos} );
14+
return React.createElement(ExampleComponent, {videos:this.props.videos} );
2015
}
2116
});
2217
@@ -34,11 +29,8 @@ class JSXTransformTest < ActionDispatch::IntegrationTest
3429
test 'asset pipeline should transform JSX + Coffeescript' do
3530
get 'assets/example2.js'
3631
assert_response :success
37-
38-
# Different coffee-script may generate slightly different outputs:
39-
# 1. Some version inserts an extra "\n" at the beginning.
40-
# 2. "/** @jsx React.DOM */" and "/** @jsx React.DOM*/" are both possible.
41-
#
32+
# Different coffee-script may generate slightly different outputs,
33+
# as some version inserts an extra "\n" at the beginning.
4234
# Because appraisal is used, multiple versions of coffee-script are treated
4335
# together. Remove all spaces to make test pass.
4436
assert_equal EXPECTED_JS_2.gsub(/\s/, ''), @response.body.gsub(/\s/, '')

0 commit comments

Comments
 (0)