From 70081a267f64464e99e80ff401752284ff307e5e Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Fri, 22 Nov 2024 10:26:39 +0100 Subject: [PATCH] fix: passing lazy loaded module to `app.current.matches(...)` --- framework/core/js/src/common/states/PageState.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/core/js/src/common/states/PageState.ts b/framework/core/js/src/common/states/PageState.ts index 3664801747..5e872834c8 100644 --- a/framework/core/js/src/common/states/PageState.ts +++ b/framework/core/js/src/common/states/PageState.ts @@ -21,7 +21,15 @@ export default class PageState { * @param {Record} data * @return {boolean} */ - matches(type: Function, data: any = {}) { + matches(type: Function | string, data: any = {}) { + if (typeof type === 'string') { + const [namespace, id] = flarum.reg.namespaceAndIdFromPath(type); + + type = flarum.reg.checkModule(namespace, id); + + if (!type) return false; + } + // Fail early when the page is of a different type if (!subclassOf(this.type, type)) return false;