IE8 getPrototypeOf Method

Pretty simple:

I have some code using Object.getPrototypeOf(...) to get the inherited Dojo widget classes (JS object only). Object.getPrototypeOf(...) not supported in IE8. I need an IE job. Any ideas? Thanks in advance.

+6
source share
3 answers

Jon Resig polyfill works http://ejohn.org/blog/objectgetprototypeof/

I made even less

 if (typeof Object.getPrototypeOf !== "function") Object.getPrototypeOf = "".__proto__ === String.prototype ? function (object) { return object.__proto__; } : function (object) { // May break if the constructor has been tampered with return object.constructor.prototype; }; 
+10
source

Classes created using Dojo.declared store metadata with their superclasses, so you don't need to use getPrototypeOf.

I think you can get the first superclass with

 MyClass.prototype.constructor._meta.bases[1] 

and its prototype with

 MyClass.prototype.constructor._meta.bases[1].prototype 

(the bases [0] seem to be the class itself)


Although why do you need a prototype? Most likely, you will eventually override some function that is already provided by Dojo.declare

0
source

Source: https://habr.com/ru/post/917474/


All Articles