Fix PathHoister attaching to default parameters. (#5415)
* Fix PathHoister attaching to default parameters. Ref: #5315 * Update hoister.js
This commit is contained in:
parent
b2c977a1b0
commit
f20da57317
@ -0,0 +1,5 @@
|
||||
function render(title= '') {
|
||||
return () => (
|
||||
<Component title={title} />
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
function render() {
|
||||
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
|
||||
var _ref = <Component title={title} />;
|
||||
|
||||
return () => _ref;
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-es2015-parameters",
|
||||
"transform-react-constant-elements",
|
||||
"transform-es2015-block-scoping",
|
||||
"syntax-jsx"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
function render(Component, text = '') {
|
||||
return function() {
|
||||
return <Component text={text} />;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
function render(Component) {
|
||||
var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
|
||||
var _ref = <Component text={text} />;
|
||||
|
||||
return function () {
|
||||
return _ref;
|
||||
};
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-es2015-parameters",
|
||||
"transform-react-constant-elements",
|
||||
"transform-es2015-block-scoping",
|
||||
"syntax-jsx"
|
||||
]
|
||||
}
|
||||
@ -133,7 +133,14 @@ export default class PathHoister {
|
||||
if (this.scope === scope) return;
|
||||
|
||||
// needs to be attached to the body
|
||||
return scope.path.get("body").get("body")[0];
|
||||
const bodies = scope.path.get("body").get("body");
|
||||
for (let i = 0; i < bodies.length; i++) {
|
||||
// Don't attach to something that's going to get hoisted,
|
||||
// like a default parameter
|
||||
if (bodies[i].node._blockHoist) continue;
|
||||
return bodies[i];
|
||||
}
|
||||
// deopt: If here, no attachment path found
|
||||
} else {
|
||||
// doesn't need to be be attached to this scope
|
||||
return this.getNextScopeAttachmentParent();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user