Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Support pure expressions in transform-react-constant-elements
- Loading branch information
Showing
9 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...in-transform-react-constant-elements/test/fixtures/constant-elements/pure-deopt/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/facebook/react/issues/3226 | ||
// Not safe to reuse because it is mutable | ||
function render() { | ||
return <div style={{ width: 100 }} />; | ||
} |
5 changes: 5 additions & 0 deletions
5
...-transform-react-constant-elements/test/fixtures/constant-elements/pure-deopt/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/facebook/react/issues/3226 | ||
// Not safe to reuse because it is mutable | ||
function render() { | ||
return <div style={{ width: 100 }} />; | ||
} |
5 changes: 5 additions & 0 deletions
5
...sform-react-constant-elements/test/fixtures/constant-elements/pure-expression-2/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function render(offset) { | ||
return function () { | ||
return <div tabIndex={offset + 1} />; | ||
}; | ||
} |
8 changes: 8 additions & 0 deletions
8
...orm-react-constant-elements/test/fixtures/constant-elements/pure-expression-2/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function render(offset) { | ||
var _ref = <div tabIndex={offset + 1} />; | ||
|
||
return function () { | ||
return _ref; | ||
}; | ||
} | ||
|
10 changes: 10 additions & 0 deletions
10
...sform-react-constant-elements/test/fixtures/constant-elements/pure-expression-3/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const OFFSET = 3; | ||
|
||
var Foo = React.createClass({ | ||
render: function () { | ||
return ( | ||
<div tabIndex={OFFSET + 1} /> | ||
); | ||
} | ||
}); | ||
|
10 changes: 10 additions & 0 deletions
10
...orm-react-constant-elements/test/fixtures/constant-elements/pure-expression-3/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const OFFSET = 3; | ||
|
||
var _ref = <div tabIndex={OFFSET + 1} />; | ||
|
||
var Foo = React.createClass({ | ||
render: function () { | ||
return _ref; | ||
} | ||
}); | ||
|
11 changes: 11 additions & 0 deletions
11
...ansform-react-constant-elements/test/fixtures/constant-elements/pure-expression/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var Foo = React.createClass({ | ||
render: function () { | ||
return ( | ||
<div data-text={ | ||
"Some text, " + | ||
"and some more too." | ||
} /> | ||
); | ||
} | ||
}); | ||
|
8 changes: 8 additions & 0 deletions
8
...sform-react-constant-elements/test/fixtures/constant-elements/pure-expression/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var _ref = <div data-text={"Some text, " + "and some more too."} />; | ||
|
||
var Foo = React.createClass({ | ||
render: function () { | ||
return _ref; | ||
} | ||
}); | ||
|