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.)
This commit is contained in:
chocolateboy
2018-06-02 16:00:02 +00:00
committed by Nicolò Ribaudo
parent b8dcd6f593
commit 2abd7839e1
6 changed files with 38 additions and 8 deletions

View File

@@ -38,7 +38,7 @@ export default {
## Defining Helpers
> **NOTE**: This package is only meant to be used by the packages inluded in this repository. There is currently no way for third-party plugins to define an helper.
> **NOTE**: This package is only meant to be used by the packages included in this repository. There is currently no way for third-party plugins to define a helper.
Helpers are defined in the `src/helpers.js` file, and they must be valid modules which follow these guidelines:
- They must have a default export, which is their entry-point.
@@ -48,7 +48,9 @@ Helpers are defined in the `src/helpers.js` file, and they must be valid modules
```js
helpers.customHelper = defineHelper(`
import dep from "dependency";
const foo = 2;
export default function getFooTimesDepPlusX(x) {
return foo * dep() + x;
}

View File

@@ -449,7 +449,7 @@ helpers.construct = () => template.program.ast`
if (Reflect.construct.sham) return false;
// Proxy can't be polyfilled. Every browser implemented
// proxies before or at the same time of Reflect.construct,
// proxies before or at the same time as Reflect.construct,
// so if they support Proxy they also support Reflect.construct.
if (typeof Proxy === "function") return true;
@@ -488,8 +488,8 @@ helpers.construct = () => template.program.ast`
// Based on https://github.com/WebReflection/babel-plugin-transform-builtin-classes
helpers.wrapNativeSuper = () => template.program.ast`
import _gPO from "getPrototypeOf";
import _sPO from "setPrototypeOf";
import getPrototypeOf from "getPrototypeOf";
import setPrototypeOf from "setPrototypeOf";
import construct from "construct";
export default function _wrapNativeSuper(Class) {
@@ -505,7 +505,7 @@ helpers.wrapNativeSuper = () => template.program.ast`
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _gPO(this).constructor)
return construct(Class, arguments, getPrototypeOf(this).constructor)
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
@@ -516,7 +516,7 @@ helpers.wrapNativeSuper = () => template.program.ast`
}
});
return _sPO(Wrapper, Class);
return setPrototypeOf(Wrapper, Class);
}
return _wrapNativeSuper(Class)