121 Commits

Author SHA1 Message Date
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
Logan Smyth
107c37715e Use .program template for helpers. 2017-10-18 13:58:47 -07:00
Logan Smyth
cc802c1e00 Reimplement 'babel-template' with better caching and tagged literal utilities. 2017-10-18 13:58:47 -07:00
Logan Smyth
fc3433c5cf Default templates to sourceType:module. 2017-10-18 13:55:14 -07:00
Henry Zhu
cde0054227 Scoped: change src imports to @babel/ [skip ci] 2017-10-16 22:49:56 -04:00
Mateusz Burzyński
88b7983e4f Fixed asyncToGenerator helper using arrow function (#6289) 2017-09-21 17:09:43 -07:00
Pranav Prakash
e98bb3dc60 Use new Array instead of Array for V8 optimization (#6250)
* Use new Array instead of Array for V8 optimization

* fix spacing [skip ci]

* Remove extraneous use strict clauses
2017-09-18 14:14:46 -04:00
Logan Smyth
158e9fbfd7 Represent helpers as simple modules. 2017-09-12 22:15:16 -07:00
Artem Yavorsky
b2b3d7944a Spec compatibility for iteratorClose condition. (#6094)
* for-of: IteratorClose spec compatibility.

See #3:
https://tc39.github.io/ecma262/#sec-iteratorclose

* Update spec fixtures for for-of.

* Fix IteratorClose case for remap-async-to-generator.

* Fix IteratorClose case for async-generator-function test output.

* Modify few tests according to iteratorClose fix.

* Fix iteratorClose for helpers.slicedToArray also.

* Update iteratorClose fixture for commonjs.
2017-08-28 13:39:02 -06:00
Justin Ridgewell
7795750862 Tests 2017-08-25 22:52:17 -04:00
Adam Miller
2d8fdf3045 Allow native Symbols as computed property names (#6705)
The for-in loop in helpers.defineEnumerableProperties doesn't iterate over Symbols.
If Object.getOwnPropertySymbols exists, include the discovered values when defining properties.
2017-08-25 22:33:51 -04:00
Nicolò Ribaudo
fb9a752262 Function sent (#5920)
* Create "babel-helper-wrap-function"

It contains the logic to wrap a function inside a call expression.
It was part of the "babel-helper-remap-async-to-generator" package, but
it is needed to transpile "function.sent"

* Create "babel-transform-function-sent"

It transforms the "function.sent" meta property by replacing it with
"yield" and making the generator ignore the first ".next()" call.

* "function.sent" is the last value passed to .next(), not the first one

* Disable exec tests on old node

* Fix flow error

* Add "transform-function-sent" to "stage-2" preset

* Do every trasformation in one traversal

* Test for "yield function.sent"

* [skip ci]

* Fix some typos [skip ci]
2017-07-25 11:07:01 -04:00
Peeyush Kushwaha
4a35243118 Non string computed keys in object-rest-spread (#5757) 2017-07-25 09:46:52 -05:00
Justin Ridgewell
797fb3c2e4 Optimize and remove state from typeof-symbol transform (#5955)
Also fixes a bug with returning a Symbol from a Class constructor
(because the transform wasn’t run on helpers before).
2017-07-17 10:51:36 -04:00
Justin Ridgewell
e170e6d760 Fix returning an object in a derived class constructor without super (#5885) 2017-07-11 17:43:19 -04:00
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
Henry Zhu
4fdff567c6 remove superClass truthy check 2017-06-24 14:27:41 -04:00