Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
608 bytes
|
Line | |
---|
1 | import setPrototypeOf from "./setPrototypeOf.js";
|
---|
2 | import isNativeReflectConstruct from "./isNativeReflectConstruct.js";
|
---|
3 | export default function _construct(Parent, args, Class) {
|
---|
4 | if (isNativeReflectConstruct()) {
|
---|
5 | _construct = Reflect.construct;
|
---|
6 | } else {
|
---|
7 | _construct = function _construct(Parent, args, Class) {
|
---|
8 | var a = [null];
|
---|
9 | a.push.apply(a, args);
|
---|
10 | var Constructor = Function.bind.apply(Parent, a);
|
---|
11 | var instance = new Constructor();
|
---|
12 | if (Class) setPrototypeOf(instance, Class.prototype);
|
---|
13 | return instance;
|
---|
14 | };
|
---|
15 | }
|
---|
16 |
|
---|
17 | return _construct.apply(null, arguments);
|
---|
18 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.