-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
I'm 99% sure this is an issue, but I haven't tested myself.
Looks like the point was raised in https://github.com/babel/babel/pull/7020/files#r156839425, but at the time it was brushed off as not a blocker because the code was specifically for subclassing builtins, which won't work on older browsers anyway.
Since then however, in @jridgewell's #7674, this code has moved into more general use, meaning that it will affect any code performing subclassing.
We currently have the helper
helpers.getPrototypeOf = () => template.program.ast`
export default function _getPrototypeOf(o) {
_getPrototypeOf = Object.getPrototypeOf || function _getPrototypeOf(o) {
return o.__proto__;
};
return _getPrototypeOf(o);
}
`;
but on IE10, it already has a getPrototypeOf, but since it doesn't have a setPrototypeOf, IE10 will simply assign .__proto__, which means that the getPrototypeOf helper will not return the prototype assigned by the setPrototypeOf helper.
To clarify, this is all about our helpers. We use helpers.getPrototypeOf(Foo).apply() for super() for instance, so even in cases where Object.setPrototypeOf is unsupported, we still need helpers.setPrototypeOf() to do something so that asking for the prototype back with helpers.getPrototypeOf() return the correct value, even if the prototype chain itself isn't actually manipulated. In Babel 6 this is accomplished by always reading .__proto__ first, so if we do foo.__proto__ in helpers.setPrototypeOf, helpers.getPrototypeOf should read .__proto__ even though Object.getPrototypeOf returns something different.