Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): polyfill removed jQuery methods

Elian Dorand43309947e26
diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts
index 795adc8cfd..f4560fa3aa 100644
--- a/apps/client/src/index.ts
+++ b/apps/client/src/index.ts
@@ -16,6 +16,17 @@ async function initJQuery() {
const $ = (await import("jquery")).default;
window.$ = $;
window.jQuery = $;
+
+ // Polyfill removed jQuery methods for autocomplete.js compatibility
+ ($ as any).isArray = Array.isArray;
+ ($ as any).isFunction = function(obj: any) { return typeof obj === 'function'; };
+ ($ as any).isPlainObject = function(obj: any) {
+ if (obj == null || typeof obj !== 'object') { return false; }
+ const proto = Object.getPrototypeOf(obj);
+ if (proto === null) { return true; }
+ const Ctor = Object.prototype.hasOwnProperty.call(proto, 'constructor') && proto.constructor;
+ return typeof Ctor === 'function' && Ctor === Object;
+ };
}
async function setupGlob() {
diff --git a/apps/client/src/runtime.ts b/apps/client/src/runtime.ts
index 4c82481b17..cab174a76d 100644
--- a/apps/client/src/runtime.ts
+++ b/apps/client/src/runtime.ts
@@ -8,6 +8,17 @@ async function loadBootstrap() {
}
}
+// Polyfill removed jQuery methods for autocomplete.js compatibility
+($ as any).isArray = Array.isArray;
+($ as any).isFunction = function(obj: any) { return typeof obj === 'function'; };
+($ as any).isPlainObject = function(obj: any) {
+ if (obj == null || typeof obj !== 'object') { return false; }
+ const proto = Object.getPrototypeOf(obj);
+ if (proto === null) { return true; }
+ const Ctor = Object.prototype.hasOwnProperty.call(proto, 'constructor') && proto.constructor;
+ return typeof Ctor === 'function' && Ctor === Object;
+};
+
(window as any).$ = $;
(window as any).jQuery = $;
await loadBootstrap();