forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix PathHoister hoisting before bindings.
Fixes babel#5149 and enables a few additional safe hoists.
- Loading branch information
Showing
8 changed files
with
125 additions
and
41 deletions.
There are no files selected for viewing
17 changes: 9 additions & 8 deletions
17
...ements/test/fixtures/constant-elements/append-to-end-when-declared-in-scope-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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
var _ref = <p>Parent</p>; | ||
|
||
var _ref2 = <div>child</div>; | ||
|
||
var _ref3 = <p>Parent</p>; | ||
|
||
(function () { | ||
class App extends React.Component { | ||
render() { | ||
return <div> | ||
{_ref} | ||
<AppItem /> | ||
</div>; | ||
return _ref; | ||
} | ||
} | ||
|
||
const AppItem = () => { | ||
return _ref2; | ||
}; | ||
}); | ||
}, | ||
_ref = <div> | ||
{_ref3} | ||
<AppItem /> | ||
</div>; | ||
}); |
18 changes: 8 additions & 10 deletions
18
...elements/test/fixtures/constant-elements/append-to-end-when-declared-in-scope/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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
var _ref = <p>Parent</p>; | ||
|
||
export default class App extends React.Component { | ||
render() { | ||
return <div> | ||
{_ref} | ||
<AppItem /> | ||
</div>; | ||
return _ref; | ||
} | ||
} | ||
|
||
var _ref2 = <div>child</div>; | ||
|
||
const AppItem = () => { | ||
const _ref2 = <div>child</div>, | ||
AppItem = () => { | ||
return _ref2; | ||
}; | ||
}, | ||
_ref = <div> | ||
<p>Parent</p> | ||
<AppItem /> | ||
</div>; |
15 changes: 15 additions & 0 deletions
15
...react-constant-elements/test/fixtures/constant-elements/dont-hoist-before-class/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,15 @@ | ||
import React from "react"; | ||
|
||
const Parent = ({}) => ( | ||
<div className="parent"> | ||
<Child/> | ||
</div> | ||
); | ||
|
||
export default Parent; | ||
|
||
let Child = () => ( | ||
<div className="child"> | ||
ChildTextContent | ||
</div> | ||
); |
13 changes: 13 additions & 0 deletions
13
...act-constant-elements/test/fixtures/constant-elements/dont-hoist-before-class/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,13 @@ | ||
import React from "react"; | ||
|
||
const Parent = ({}) => _ref; | ||
|
||
export default Parent; | ||
|
||
let _ref2 = <div className="child"> | ||
ChildTextContent | ||
</div>, | ||
Child = () => _ref2, | ||
_ref = <div className="parent"> | ||
<Child /> | ||
</div>; |
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
18 changes: 18 additions & 0 deletions
18
...m-react-constant-elements/test/fixtures/constant-elements/dont-hoist-before-hoc/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,18 @@ | ||
import React from "react"; | ||
|
||
const HOC = component => component; | ||
|
||
const Parent = ({}) => ( | ||
<div className="parent"> | ||
<Child/> | ||
</div> | ||
); | ||
|
||
export default Parent; | ||
|
||
let Child = () => ( | ||
<div className="child"> | ||
ChildTextContent | ||
</div> | ||
); | ||
Child = HOC(Child); |
18 changes: 18 additions & 0 deletions
18
...react-constant-elements/test/fixtures/constant-elements/dont-hoist-before-hoc/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,18 @@ | ||
import React from "react"; | ||
|
||
const HOC = component => component; | ||
|
||
const Parent = ({}) => _ref; | ||
|
||
export default Parent; | ||
|
||
var _ref2 = <div className="child"> | ||
ChildTextContent | ||
</div>; | ||
|
||
let Child = () => _ref2; | ||
Child = HOC(Child); | ||
|
||
var _ref = <div className="parent"> | ||
<Child /> | ||
</div>; |
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