Fix derived classes in Chrome <= 36 (#14072)
This commit is contained in:
parent
e77e3de402
commit
2810dc6460
@ -335,16 +335,17 @@ helpers.inherits = helper("7.0.0-beta.0")`
|
|||||||
if (typeof superClass !== "function" && superClass !== null) {
|
if (typeof superClass !== "function" && superClass !== null) {
|
||||||
throw new TypeError("Super expression must either be null or a function");
|
throw new TypeError("Super expression must either be null or a function");
|
||||||
}
|
}
|
||||||
Object.defineProperty(subClass, "prototype", {
|
// We can't use defineProperty to set the prototype in a single step because it
|
||||||
value: Object.create(superClass && superClass.prototype, {
|
// doesn't work in Chrome <= 36. https://github.com/babel/babel/issues/14056
|
||||||
constructor: {
|
// V8 bug: https://bugs.chromium.org/p/v8/issues/detail?id=3334
|
||||||
value: subClass,
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||||
writable: true,
|
constructor: {
|
||||||
configurable: true
|
value: subClass,
|
||||||
}
|
writable: true,
|
||||||
}),
|
configurable: true
|
||||||
writable: false,
|
}
|
||||||
});
|
});
|
||||||
|
Object.defineProperty(subClass, "prototype", { writable: false });
|
||||||
if (superClass) setPrototypeOf(subClass, superClass);
|
if (superClass) setPrototypeOf(subClass, superClass);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user