From 38723a7df5460e08eed38c2f3b4df14716edbe32 Mon Sep 17 00:00:00 2001 From: Kevin Garner Date: Sun, 14 Jan 2024 10:40:16 -0600 Subject: [PATCH] Updated `hack` function to crawl up a varying number of prototypes (up to 100 prototypal ancestors; excessive on purpose), to find the correct ItemSheet class. This change supports sheets like Tidy 5e and the Tidy 5e Alpha rewrite, which have a different number of parent classes than the default sheets. --- src/scripts/magicItemtab.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/scripts/magicItemtab.js b/src/scripts/magicItemtab.js index c74ce19..8cbb011 100644 --- a/src/scripts/magicItemtab.js +++ b/src/scripts/magicItemtab.js @@ -71,9 +71,16 @@ export class MagicItemTab { hack(app) { let tab = this; - app.setPosition = function (position = {}) { + app.setPosition = function(position = {}) { position.height = tab.isActive() && !position.height ? "auto" : position.height; - return this.__proto__.__proto__.setPosition.apply(this, [position]); + let that = this; + for (let i = 0; i < 100; i++) { + if (that.constructor.name === ItemSheet.name) { + break; + } + that = Object.getPrototypeOf(that); + } + return that.setPosition.apply(this, [position]); }; }