ZeroXNoxus / dark-mode-5e

2 stars 0 forks source link

V11 Compatibility - "themeClass is not defined" #3

Closed tehguitarist closed 12 months ago

tehguitarist commented 1 year ago

This may or may not be on the cards, but I got this error when trying the module in V11.

ReferenceError: Error thrown in hooked function '' for hook 'init'. themeClass is not defined
[Detected 2 packages: dark-mode-5e, lib-wrapper]
    <anonymous> dark-mode.js:67
    #call foundry.js:730
    callAll foundry.js:687
    initialize foundry.js:8573
    call_wrapped libWrapper-wrapper.js:507
    libWrapperInit libWrapper-api.js:803
    initialize#0 libWrapper-wrapper.js:187
    <anonymous> foundry.js:90585
    async* foundry.js:90561
[foundry.js:753:30](https://myurl.com/scripts/foundry.js)
    onError foundry.js:753
    call_wrapped libWrapper-wrapper.js:507
    <anonymous> listeners.js:135
    onError#0 libWrapper-wrapper.js:187
    #call foundry.js:734
    callAll foundry.js:687
    initialize foundry.js:8573
    call_wrapped libWrapper-wrapper.js:507
    libWrapperInit libWrapper-api.js:803
    initialize#0 libWrapper-wrapper.js:187
    <anonymous> foundry.js:90585
    <anonymous> foundry.js:90561

Or without libwrapper.

ReferenceError: Error thrown in hooked function '' for hook 'init'. themeClass is not defined
    <anonymous> https://myurl.com/modules/dark-mode-5e/script/dark-mode.js:67
    #call https://myurl.com/scripts/foundry.js:730
    callAll https://myurl.com/scripts/foundry.js:687
    initialize https://myurl.com/scripts/foundry.js:8573
    <anonymous> https://myurl.com/scripts/foundry.js:90585
[foundry.js:753:30](https://myurl.com/scripts/foundry.js)
    onError https://myurl.com/scripts/foundry.js:753
    #call https://myurl.com/scripts/foundry.js:734
    callAll https://myurl.com/scripts/foundry.js:687
    initialize https://myurl.com/scripts/foundry.js:8573
    <anonymous> https://myurl2.com/scripts/foundry.js:90585
ZeroXNoxus commented 12 months ago

I'll take a look into it, I haven't upgraded to v11 yet, but I'll fix this asap. Thanks for the heads-up!

MiniGrief commented 12 months ago

That specific error is occuring because themeClass is defined in initialize which isn't even called until you open a sheet. It needs moving elsewhere so it is defined earlier in a global scope.

Declaring them as let seems wrong too as you cannot modify a let variable in the future, which you are trying to do.

This also should be done with the theme variable too due to the same situation.

ZeroXNoxus commented 12 months ago

That specific error is occuring because themeClass is defined in initialize which isn't even called until you open a sheet. It needs moving elsewhere so it is defined earlier in a global scope.

Declaring them as let seems wrong too as you cannot modify a let variable in the future, which you are trying to do.

Ah, thanks for pointing that out. It'll be fixed with the next release!