Fix PathHoister hoisting before bindings. (#5153)

Fixes #5149 and enables a few additional safe hoists.
This commit is contained in:
Samuel Reed
2017-02-13 09:35:08 +07:00
committed by Logan Smyth
parent eb91bd831c
commit f4e3dfee74
8 changed files with 125 additions and 41 deletions

View File

@@ -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>;
});

View File

@@ -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>;

View File

@@ -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>
);

View File

@@ -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>;

View File

@@ -8,8 +8,9 @@ function render() {
function render() {
const bar = "bar",
renderFoo = () => <foo bar={bar} baz={baz} />,
baz = "baz";
renderFoo = () => _ref2,
baz = "baz",
_ref2 = <foo bar={bar} baz={baz} />;
return renderFoo();
}

View File

@@ -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);

View File

@@ -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>;