Skip to content

Commit 2810dc6

Browse files
Fix derived classes in Chrome <= 36 (#14072)
1 parent e77e3de commit 2810dc6

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

packages/babel-helpers/src/helpers.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,17 @@ helpers.inherits = helper("7.0.0-beta.0")`
335335
if (typeof superClass !== "function" && superClass !== null) {
336336
throw new TypeError("Super expression must either be null or a function");
337337
}
338-
Object.defineProperty(subClass, "prototype", {
339-
value: Object.create(superClass && superClass.prototype, {
340-
constructor: {
341-
value: subClass,
342-
writable: true,
343-
configurable: true
344-
}
345-
}),
346-
writable: false,
338+
// We can't use defineProperty to set the prototype in a single step because it
339+
// doesn't work in Chrome <= 36. https://github.com/babel/babel/issues/14056
340+
// V8 bug: https://bugs.chromium.org/p/v8/issues/detail?id=3334
341+
subClass.prototype = Object.create(superClass && superClass.prototype, {
342+
constructor: {
343+
value: subClass,
344+
writable: true,
345+
configurable: true
346+
}
347347
});
348+
Object.defineProperty(subClass, "prototype", { writable: false });
348349
if (superClass) setPrototypeOf(subClass, superClass);
349350
}
350351
`;

0 commit comments

Comments
 (0)