1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 03:44:32 +02:00

fix: passing lazy loaded module to app.current.matches(...)

This commit is contained in:
Sami Mazouz
2024-11-22 10:26:39 +01:00
parent 70158aa0ef
commit 70081a267f

View File

@@ -21,7 +21,15 @@ export default class PageState {
* @param {Record<string, unknown>} 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;