};
}
-const defaultFunctions = Object.getOwnPropertyNames(Object.getPrototypeOf({}));
-
export function enableLegacyInheritance<T>(legacyClass: T): void {
(legacyClass as any).call = function (thisValue, ...args) {
if (window.ENABLE_DEVELOPER_TOOLS) {
const constructed = Reflect.construct(legacyClass as any, args, thisValue.constructor);
Object.entries(constructed).forEach(([key, value]) => {
+ if (typeof value === "function") {
+ value = value.bind(thisValue);
+ }
+
thisValue[key] = value;
});
- let object = thisValue;
- while ((object = Object.getPrototypeOf(object))) {
- Object.getOwnPropertyNames(object).forEach((name) => {
- if (typeof object[name] === "function" && !defaultFunctions.includes(name)) {
- object[name] = object[name].bind(thisValue);
- }
- });
+ for (const key in thisValue) {
+ if (typeof thisValue[key] === "function") {
+ constructed[key] = thisValue[key].bind(thisValue);
+ }
}
};
}
};
}
exports.debounce = debounce;
- const defaultFunctions = Object.getOwnPropertyNames(Object.getPrototypeOf({}));
function enableLegacyInheritance(legacyClass) {
legacyClass.call = function (thisValue, ...args) {
if (window.ENABLE_DEVELOPER_TOOLS) {
}
const constructed = Reflect.construct(legacyClass, args, thisValue.constructor);
Object.entries(constructed).forEach(([key, value]) => {
+ if (typeof value === "function") {
+ value = value.bind(thisValue);
+ }
thisValue[key] = value;
});
- let object = thisValue;
- while ((object = Object.getPrototypeOf(object))) {
- Object.getOwnPropertyNames(object).forEach((name) => {
- if (typeof object[name] === "function" && !defaultFunctions.includes(name)) {
- object[name] = object[name].bind(thisValue);
- }
- });
+ for (const key in thisValue) {
+ if (typeof thisValue[key] === "function") {
+ constructed[key] = thisValue[key].bind(thisValue);
+ }
}
};
}