Skip to content

Commit

Permalink
[[Fix]] Do not disable ES6 when moz is set
Browse files Browse the repository at this point in the history
Although environments implementing Mozilla extensions are not
necessarily ES6-compliant, they are not mutually exclusive. Ensure that
for configurations that specify both ES6 and `moz`, the semantics of
both environments are applied consistently.
  • Loading branch information
jugglinmike committed Dec 6, 2015
1 parent 46db923 commit 97dfd90
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ var state = {

/**
* @param {boolean} strict - When `true`, only consider ES6 when in
* "esversion: 6" code and *not* in "moz".
* "esversion: 6" code.
*/
inES6: function(strict) {
if (strict) {
return !this.option.moz && this.option.esversion === 6;
return this.option.esversion === 6;
}
return this.option.moz || this.option.esversion >= 6;
},
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,26 @@ exports.esnext = function (test) {
test.done();
};

// The `moz` option should not preclude ES6
exports.mozAndEs6 = function (test) {
var src = [
"var x = () => {};",
"function* toArray(...rest) {",
" void new.target;",
" yield rest;",
"}",
"var y = [...x];"
];

TestRun(test)
.test(src, { esversion: 6 });

TestRun(test)
.test(src, { esversion: 6, moz: true });

test.done();
};

/*
* Tests the `maxlen` option
*/
Expand Down

0 comments on commit 97dfd90

Please sign in to comment.