87 Commits

Author SHA1 Message Date
Nicolò Ribaudo
d35563ee1a Set correct methods name 2018-11-02 13:59:57 +01:00
Nicolò Ribaudo
38397ce11f Use toPropertyKey in the "decorate" helper
This commit also makes the "toPropertyKey" helper call @@toPrimitive
when needed.
2018-11-02 13:59:57 +01:00
Nicolò Ribaudo
5150f5f500
[decorators] Fields are enumerable (#8761) 2018-09-24 23:36:32 +02:00
Nicolò Ribaudo
aac8118b7f
Update helpers version fro 7.0.1 to 7.0.2 (#8703) 2018-09-14 22:55:27 +02:00
Nicolò Ribaudo
9aec4ad159
Add support for the new decorators proposal (#7976) 2018-09-07 15:58:42 +02:00
Nicolò Ribaudo
c5279eeca4
[static private] Use explicit descriptors instead of an object (#8620)
This is similar to ec69b4bb1256c061ac76f53dfed09c4283ec6a31, which
was about private instance fields.

Private properties can be non-writable (thanks to decorators), or have
get/set accessors. If we stored this information on the `privateClass`
object, we would need to always use `Object.getOwnPropertyDescriptor`
before reading or writing a property because accessors need to be called
with the correct `this` context (it should be the actual class, not the
object hat stores the private properties). This commit simplifies that
operation a bit by removing the container object.

It also have another advantage, which instance fields already have
thanks to the use of separate weakmaps: unused private static fields
can be tree-shaken away or garbage-collected, while properties of an
object can't. Also, they can be easilier minified.
2018-09-05 15:08:40 +02:00
Nicolò Ribaudo
d4e23b5b2a
[static private] Unify loose handling of static and instance props (#8614) 2018-09-04 08:10:46 +02:00
Nicolò Ribaudo
4beb977f15 [static private] Use correct min version in helpers (#8613)
* [staic private] Use correct min version in helpers

* Always use patch version
2018-09-03 11:36:26 -07:00
Robin Ricard
fb66fa6f90 Private Static Fields Features: Stage 3 (#8205)
* Private Static Class Fields Implementation

* Redo testing without class transform for static private

* Add a call() test for private static

* Use Object.defineProperty in loose mode
2018-09-01 00:42:18 -04:00
Nicolò Ribaudo
1f9b2a5c41
[_wrapNativeSuper] Don't wrap non-native constructors (#8501) 2018-08-24 19:58:49 +02:00
Nicolò Ribaudo
c5e3b6d4bc
[decorators] Don't set writable on accessors (#8513) 2018-08-23 00:54:28 +02:00
Yeonghoon Park
c75a00bd56 Fix default descriptor setting for class properties with decorators (#7429)
(legacy decorators)
2018-08-17 10:49:03 +02:00
Logan Smyth
eb0e999987 Expose a minimum required Babel version for each helper. 2018-08-02 18:44:56 -07:00
Nicolò Ribaudo
ec69b4bb12 Save full descriptor instead of only value for private fields. (#8318)
* Save full descriptor instead of only value for private fields.

Decorators can make private fields non-writable, so we need to store this
information somewhere.
The descriptor can also be used to implement private accessors.
2018-07-27 16:24:57 -04:00
Mateusz Burzyński
c0c13ae30f Introduce objectWithoutPropertiesLoose helper (#8261) 2018-07-06 15:03:44 -04:00
Justin Ridgewell
e229ebbb8a
Optimize async to generator (#8267)
* Optimize async to generator

We can reuse the step function, avoiding a closure on every invocation.

* Rename step
2018-07-05 10:51:16 -04:00
chocolateboy
2abd7839e1 Fix ReferenceError in the wrapNativeSuper helper (#8100)
Fix a ReferenceError caused by a typo (`_construct` instead of
`construct`) in the external `wrapNativeSuper` helper. (The typo
doesn't usually cause an error in inline helpers because `_construct`
happens to be the default name given to the `construct` helper
function.)
2018-06-02 18:00:02 +02:00
Justin Ridgewell
2af7a33c4e Fix class inheritance in IE10 (#7969)
* Revert "Move subclass inheritance to end (#7772)"

This reverts commit f8ab9466d331871a90f458af40b14e8d831e0c29.

* Only use getPrototypeOf if setPrototypeOf is implemented

* Update fixtures

* Helpers updates

* Update fixtures

* Fall back to getPrototypeOf

* Update fixtures
2018-05-23 16:21:21 -04:00
Justin Ridgewell
27c39c512d
Class private properties (#7842)
* Update member-expression-to-functions

1. Babel using British spellings, so `memoise`
2. Provide a helper `AssignmentMemoiser` class, which will assign the memo'd value with the `n`th access.

* Private properties!

* Fixes

* Tests

* Update helper name

* Fix privates that reference other privates

* Don't extend a builtin

* Rebase
2018-05-18 14:03:23 -04:00
Nicolò Ribaudo
2351a638b5
Fix bugs in the _wrapNativeSuper helper (#7533)
* Remove second wrapper from _wrapNativeSuper

* Fix tests on node 4

I DON'T KNOW WHY IT WORKS.

* Update fixtures

* Use Reflect.construct

* Parens

* Fix things

* Fix things

* Undo changes

* Fix with sham

* Typo
2018-05-18 00:04:12 +02:00
Michael McGlynn
a5edab7393 Change const to var inside helper 2018-04-26 23:33:12 +02:00
Justin Ridgewell
f8ab9466d3
Move subclass inheritance to end (#7772)
We were using `Object.create` to setup the prototype chain at the start of the class definition, which lead to #7771.

I was a bit worried about a speed hit, but it seems everyone optimizes the two patterns the same way.
https://jsbench.github.io/#f9fca52407643d96458a35763b201215

Fixes #7771.
2018-04-21 17:31:44 -04:00
Jason Quense
2bded404f3 Improve asyncIterator error (#7745)
* Improve asyncIterator error

When an object is has neither asyncIterator or iterator defined, throw the "not an async iterable" error

* Correct logic

* reduce access

* Update helpers.js
2018-04-17 21:02:53 -05:00
Justin Ridgewell
ec3722b3f9
Get set helpers (#7687)
* Improve get/set helper

* fixtures

* Edge cases

* Add loose edge cases

* Spec compliant

* Add issue case

* Even more edge cases!

* Final updates

* Fix name

* Use Reflect.{get, set} when available

* Avoid block scoping in loose

* Remove semicolon

* Do not redefine a non-enumerable

* Get strictness from call site, not helpers

* Add called assertions

* Classes are always strict

* Update test fixture
2018-04-11 11:56:59 -04:00
Guy Bedford
5b1332457c arrayWithHoles internal function name consistency (#7709) [skip ci] 2018-04-10 09:33:54 -04:00
Justin Ridgewell
d17adf40df
Use construct helper in New Spread (#7677)
* Use construct helper in New Spread

* CircleCI
2018-04-06 10:40:38 +01:00
Justin Ridgewell
e9ed0f5f21
Split _wrapNativeSuper into helpers (#7674)
These can be reused in a few transforms.
2018-04-06 01:18:44 +01:00
Daniel Tschinder
f0d681a238 Remove obsolete max-len eslint rule and reformat some stuff to fit (#7602) 2018-03-20 08:51:47 -05:00
Mateusz Burzyński
586d3b5929
Wrap wrapNativeSuper helpers in redefining functions for better tree-shakeability (#7188) 2018-03-14 23:48:33 +01:00
Simon Kjellberg
07ab02f6b2 Fix incorrect value of _cache in _wrapNativeSuper (#7570)
The boolean expressions returns false in environments where Map is missing.
This change explicitly sets _cache to undefined in such cases, to ensure the cache methods will be ignored.
2018-03-14 16:37:51 -04:00
Nicolò Ribaudo
91a114f74a [transform-classes] Fix typo in _wrapNativeSuper helper 2018-03-14 19:23:10 +01:00
Logan Smyth
4da3f3bc64
Update helpers from #7491. (#7532) 2018-03-08 17:06:43 -08:00
Logan Smyth
1c9b0ff49e
Merge pull request #7491 from loganfsmyth/require-array-rest-spread-iterable
Explicitly throw if the array rest/spread items are not iterable.
2018-03-08 12:39:53 -08:00
Logan Smyth
eaa31b6ec3 Explicitly throw if the rest/spread items are not iterable. 2018-03-05 09:32:40 -08:00
Logan Smyth
4d76d5dddc Refactor Babel's helpers into smaller functions. 2018-03-05 09:32:39 -08:00
Nicolò Ribaudo
a86d311986 Reuse the assertThisInitialized helper in possibleConstructorReturn (#7493) 2018-03-05 08:11:16 -08:00
Logan Smyth
dffcef785a Lazy-initialize helper templates. 2018-02-26 18:18:57 -08:00
Deepak Pai
dad05ed503 Solves Tagged template literal size optimization (#7379)
* Tagged template literal size optimization
solves #7352

* Incorporates review changes
2018-02-20 15:39:22 -05:00
Andrea Puddu
ee6dfd1580 Fix object spread according to spec (#7034) 2018-02-16 20:06:17 -05:00
Jorrit Schippers
3c8d831fe4 Prevent object shape change in jsx helper (#7170)
Keeping the shape of an object constant is a performance improvement for modern javascript engines. At the point of the code change it is certain that the `children` property will be set later, so the property can already be set to `undefined`.
2018-01-15 16:37:57 +01:00
Nicolò Ribaudo
ae3f5b9149
Return the obj in setPrototypeOf fallback (#7080) 2017-12-20 22:48:10 +01:00
Nicolò Ribaudo
0c885b3200 Add support for extending builtins (#7020) 2017-12-20 14:46:00 -05:00
Peri Nikhil
9cc0a26694 Move helpers from 'babel-plugin-proposal-decorators' to 'babel-helpers' (#7017) 2017-12-13 16:08:19 +01:00
Nicolò Ribaudo
509dbb7302
this before super() is a runtime error, not a static one. (#6467)
* Check that super.* is after super() at runtime

* "missing super() call in constructor" runtime

* "'this' is not allowed before super()" runtime
2017-12-06 06:46:54 +01:00
Daniel Tschinder
9d9710c765 Copy getters and setters correctly in interopWildcard (#6850) 2017-11-30 15:50:10 -06:00
Mauro Bringolf
6330a152ce Implement TDZ for ClassFieldDefinitionEvaluation (#6855)
* First implementation sketch and testcase

* Use helper instead of inline IIFE's

* minNodeVersion 6.0.0

* Hoisted visitor for subtraversal and fixed edgest case

* Resolve merge conflicts in helpers

* Remove duplicated helper from messing up Git
2017-11-26 16:56:04 +01:00
Mauro Bringolf
ba441c5ce4 Define readOnlyError helper and use in check-constants plugin 2017-11-20 16:41:15 +01:00
Mateusz Burzyński
4684edaec7 Adhering to async generator yield behavior change (#6452) 2017-10-21 21:48:27 +02:00
Mateusz Burzyński
54aa4cb3f9 Fixed async generator named declarations with inline helpers 2017-10-20 14:23:27 +02:00
Nicolò Ribaudo
e0a6e1e864 Import temporalUndefined inside temporalRef helper 2017-10-19 00:32:43 +02:00