Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Fix: Cannot completely load modules
Browse files Browse the repository at this point in the history
  • Loading branch information
AnYiEE committed Oct 5, 2023
1 parent ba6f99c commit 4195102
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion static/wikimirror.js

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions static/wikimirror.tsc.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,14 @@
async init() {
const moduleLoader = (modules) => {
for (const [moduleName, {enable, isStatic, parameter}] of Object.entries(modules)) {
if (WikiMirrorPrivateMethod.isValidKey(this, moduleName) && enable) {
if (isStatic) {
WikiMirrorPrivateMethod[moduleName](parameter);
} else {
this[moduleName](parameter);
}
if (!enable) {
continue;
}
const target = isStatic ? WikiMirrorPrivateMethod : this;
if (!WikiMirrorPrivateMethod.isValidKey(target, moduleName, false)) {
continue;
}
target[moduleName](parameter);
}
};
// stand alone functions
Expand Down Expand Up @@ -1895,8 +1896,9 @@
},
};
}
static isValidKey(object, key) {
return Object.hasOwn(object, key) && key in object;
static isValidKey(object, key, checkOwnPropertyOnly = true) {
const isOwnProperty = checkOwnPropertyOnly ? Object.hasOwn(object, key) : true;
return isOwnProperty && key in object;
}
static localStorage(name, value) {
const isStorageEnable = (() => {
Expand Down

0 comments on commit 4195102

Please sign in to comment.