* Return inserted/replaced paths This gives `Path`’s replacement and insertion methods a consistent return value: the inserted/replaced paths. Before, they could return `undefined`, a `node`, or a the current path inside an array. It was kinda pointless. But now they always return an array of paths, which is useful for solving https://github.com/babel/babel/pull/4935#discussion_r96151368. * Return inserted nodes and not BlockStatement Addded test for bug #4363 * Cleanups - `#replaceWith` will now return the current path if it's the same node - `#insertAfter` and `#insertBefore` use public Path APIs now - Makes container insertion faster (single splice call) - Use public APIs in container insertion - Replacing a statement with an expression returns the expression's path - Replacing an expression with multiple statements returns the inserted closure's body's paths.
44 lines
634 B
JavaScript
44 lines
634 B
JavaScript
function WithoutCurlyBraces() {
|
|
var _this = this;
|
|
|
|
if (true) {
|
|
var _loop = function (k) {
|
|
function foo() {
|
|
return this;
|
|
}
|
|
|
|
function bar() {
|
|
return foo.call(this);
|
|
}
|
|
|
|
console.log(_this, k); // => undefined
|
|
};
|
|
|
|
for (var k in kv) {
|
|
_loop(k);
|
|
}
|
|
}
|
|
}
|
|
|
|
function WithCurlyBraces() {
|
|
var _this2 = this;
|
|
|
|
if (true) {
|
|
var _loop2 = function (k) {
|
|
function foo() {
|
|
return this;
|
|
}
|
|
|
|
function bar() {
|
|
return foo.call(this);
|
|
}
|
|
|
|
console.log(_this2, k); // => 777
|
|
};
|
|
|
|
for (var k in kv) {
|
|
_loop2(k);
|
|
}
|
|
}
|
|
}
|