Skip to content

Instantly share code, notes, and snippets.

@dgeibi
Last active May 1, 2024 21:04
Show Gist options
  • Select an option

  • Save dgeibi/fbb68e241b10a92988ff554b0473611a to your computer and use it in GitHub Desktop.

Select an option

Save dgeibi/fbb68e241b10a92988ff554b0473611a to your computer and use it in GitHub Desktop.
/*
DO NOT USE THIS POLYFILL
because `instanceof` operator won't work
copy from
https://github.com/paulmillr/es6-shim
https://github.com/wesleytodd/setprototypeof
https://github.com/zloirock/core-js
*/
Object.setPrototypeOf =
Object.setPrototypeOf || { __proto__: null } instanceof Object
? (function() {
function has(obj, k) {
return Object.prototype.hasOwnProperty.call(obj, k);
}
var getPrototypeOf = Object.getPrototypeOf;
Object.getPrototypeOf = function gpo(O) {
if (O == undefined)
throw TypeError("Cannot convert undefined or null to object");
O = Object(O);
if (has(O, "__proto__")) return O.__proto__;
if (getPrototypeOf) return getPrototypeOf(O);
if (
typeof O.constructor === "function" &&
O instanceof O.constructor
) {
return O.constructor.prototype;
}
return O instanceof Object ? Object.prototype : null;
};
return function mixinProperties(obj, proto) {
Object.defineProperty(obj, "__proto__", {
value: proto,
enumerable: false,
writable: true,
configurable: true
});
var keys = Object.getOwnPropertyNames(proto);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (!has(obj, key)) {
var descriptor = Object.getOwnPropertyDescriptor(proto, key);
descriptor.configurable = true;
Object.defineProperty(obj, key, descriptor);
}
}
return obj;
};
})()
: function setProtoOf(obj, proto) {
obj.__proto__ = proto;
return obj;
};
@ganyanchuan1989
Copy link

https://github.com/dgeibi/spo-gpo/blob/master/index.js
感谢,解决了ant-design-pro 在IE10 中提示如下错误:

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");  // 这里报错
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment