Skip to content

Commit

Permalink
Updated hack function to crawl up a varying number of prototypes (u…
Browse files Browse the repository at this point in the history
…p 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.
  • Loading branch information
kgar committed Jan 14, 2024
1 parent f2c8725 commit 38723a7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/scripts/magicItemtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
};
}

Expand Down

0 comments on commit 38723a7

Please sign in to comment.