From 6c173507a51f6cca404317f1a1a6bb59d374c543 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Thu, 10 Oct 2024 15:50:50 +0200 Subject: [PATCH] Fix js override for registerClass signature with a single argument --- src/overrides.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/overrides.js b/src/overrides.js index b816f8118..2d157119b 100644 --- a/src/overrides.js +++ b/src/overrides.js @@ -30,13 +30,23 @@ export function overrides() { // https://gitlab.gnome.org/GNOME/glib/-/issues/2336 // https://gitlab.gnome.org/GNOME/glib/-/issues/667 GObject.registerClass = function registerWorkbenchClass(...args) { - const klass = args[0]; - const GTypeName = klass.GTypeName || args[1]?.name; + let attrs; + let klass; + + if (args.length === 1) { + attrs = {}; + klass = args[0]; + } else { + attrs = args[0]; + klass = args[1]; + } + + const GTypeName = attrs.GTypeName || klass.name; if (GTypeName) { types[GTypeName] = increment(GTypeName); - klass.GTypeName = GTypeName + types[GTypeName]; + attrs.GTypeName = GTypeName + types[GTypeName]; } - return registerClass(...args); + return registerClass(attrs, klass); }; // This is used to tweak `workbench.template` in order to set the //