add loose mode for es6.spread and es6.destructuring that assumes all values are arrays - emberjs/ember.js#10730
This commit is contained in:
parent
902ebd3fe7
commit
710a7f882d
@ -434,7 +434,11 @@ class DestructuringTransformer {
|
||||
// return a locally bound identifier if it's been inferred to be an array,
|
||||
// otherwise it'll be a call to a helper that will ensure it's one
|
||||
|
||||
var toArray = this.scope.toArray(arrayRef, count);
|
||||
var toArray = arrayRef;
|
||||
|
||||
if (!this.file.isLoose("es6.destructuring")) {
|
||||
toArray = this.scope.toArray(arrayRef, count);
|
||||
}
|
||||
|
||||
if (t.isIdentifier(toArray)) {
|
||||
// we've been given an identifier so it must have been inferred to be an
|
||||
@ -457,7 +461,11 @@ class DestructuringTransformer {
|
||||
var elemRef;
|
||||
|
||||
if (t.isRestElement(elem)) {
|
||||
elemRef = this.scope.toArray(arrayRef);
|
||||
elemRef = arrayRef;
|
||||
|
||||
if (!this.file.isLoose("es6.destructuring")) {
|
||||
elemRef = this.scope.toArray(arrayRef);
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
elemRef = t.callExpression(t.memberExpression(elemRef, t.identifier("slice")), [t.literal(i)]);
|
||||
|
||||
@ -2,7 +2,11 @@ import includes from "lodash/collection/includes";
|
||||
import * as t from "../../../types";
|
||||
|
||||
function getSpreadLiteral(spread, scope) {
|
||||
return scope.toArray(spread.argument, true);
|
||||
if (scope.file.isLoose("es6.spread")) {
|
||||
return spread.argument;
|
||||
} else {
|
||||
return scope.toArray(spread.argument, true);
|
||||
}
|
||||
}
|
||||
|
||||
function hasSpread(nodes) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user