fix some bugs in PathHoister - fixes babel-plugins/babel-plugin-react-constant-elements#1
- Don't hoist constant elements to the same function as their original paths function parent. - Push each violation paths ancestry to the breakOnScopePaths collection to avoid constant hoisting to nested paths.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
function render() {
|
||||
var children = <b></b>;
|
||||
|
||||
if (someCondition) {
|
||||
children = <span></span>;
|
||||
}
|
||||
|
||||
return <div>{children}</div>;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
var _ref = <b></b>;
|
||||
|
||||
var _ref2 = <span></span>;
|
||||
|
||||
function render() {
|
||||
var children = _ref;
|
||||
|
||||
if (someCondition) {
|
||||
children = _ref2;
|
||||
}
|
||||
|
||||
return <div>{children}</div>;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
function renderSome(a, b) {
|
||||
if (a) {
|
||||
return <div>{b}</div>
|
||||
} else {
|
||||
return <span>{b}</span>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
function renderSome(a, b) {
|
||||
if (a) {
|
||||
return <div>{b}</div>;
|
||||
} else {
|
||||
return <span>{b}</span>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user