9 Commits

Author SHA1 Message Date
Dan Harper
33eb56ab09 fix error when constructor default arg refers to own static property or self (#4666)
(closes #4253)
(closes #4442)
2016-10-05 17:52:42 -04:00
Justin Ridgewell
c2ed9de7fb Flip default parameter template (#4515)
* Flip default parameter template

YMMV, I saved ~10b on a 2kb library. Not noticeable at the small scale, by why not do it anyway?

I've (unscientifically) found that flipping the default parameter conditional yields better gzip results. I think this is due to the slightly longer string it can now repeatedly match:

```js
// old
var param = arguments.length <= 0 || void 0 === arguments[0] ? null : arguments[0]
--------------------------------------------------------------^

// new
var param = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null
------------------------------------------------------------------------^
```

Though it's entirely likely gzip will also choose up to the index of the arguments if you many default parameters at different indexes.

* Update tests
2016-09-25 14:05:53 -07:00
Justin Ridgewell
9a6890c92f Default parameters cleanup (#3574)
* Remove buildDefaultParamAssign

This seems to have been
[added](https://github.com/babel/babel/commit/4b85b05839017ab2abc03ba2d1
e875a63f002890) in v5.5.4 to address
[#1690](https://phabricator.babeljs.io/T1690). It [became
“dead”](https://github.com/babel/babel/blob/v6.0.0/packages/babel-core/t
est/fixtures/transformation/es6.parameters/default-before-last/expected.
js) (as far as I can tell) in the [v6.0.0
commit](https://github.com/babel/babel/commit/ae7d5367f1c3d438667242d692
5db024f875fccd).

Either way, this code is never executed.

- `pushDefNode` is only called when the param is a default param.
- `buildDefaultParamAssign` (which is inside `pushDefNode`) only runs
of the param index is less than or equals to the lastNonDefaultParam.
AKA, is this param before any non-defaulting params.

Which is a contradiction.

* Small optimization

No need to check if we need an iife if we already know we need one.
2016-07-18 11:03:59 -04:00
Amjad Masad
3667527d04 Revert "Remove flow"
This reverts commit 2827ff6b01dcce69e9d3c0402e96b52b3a2a47ee.
2016-03-03 14:49:20 -08:00
Sam Goldman
2827ff6b01 Remove flow 2016-03-01 22:33:30 -08:00
Sebastian McKenzie
5b89849f43 Switch to klint, fix some lint rules 2016-02-14 23:25:14 +00:00
Sebastian McKenzie
e62a00df50 rename NumberLiteral to NumericLiteral and RegexLiteral to RegExpLiteral 2015-11-03 01:19:35 +00:00
Sebastian McKenzie
5c7f88a5fb fix parameters after defaults in arrow functions refering to the wrong arguments - fixes #2682 2015-10-30 17:39:57 +00:00
Sebastian McKenzie
ae7d5367f1 6.0.0
I'm extremely stupid and didn't commit as I go. To anyone reading this
I'm extremely sorry. A lot of these changes are very broad and I plan on
releasing Babel 6.0.0 today live on stage at Ember Camp London so I'm
afraid I couldn't wait. If you're ever in London I'll buy you a beer
(or assorted beverage!) to make up for it, also I'll kiss your feet and
give you a back massage, maybe.
2015-10-29 17:51:24 +00:00