From b38715e605449c5e4b28115a76edb85ac98346c3 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 20 Oct 2023 17:54:15 +0100 Subject: [PATCH] DEV: Actually fix decorateWidget error checking logic (#24037) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to separate the `:before` / `:after` suffix before looking up in the registry 🤦‍♂️🤦‍♂️ --- app/assets/javascripts/discourse/app/widgets/widget.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/widget.js b/app/assets/javascripts/discourse/app/widgets/widget.js index f3374eb442e..8e5035dc7ac 100644 --- a/app/assets/javascripts/discourse/app/widgets/widget.js +++ b/app/assets/javascripts/discourse/app/widgets/widget.js @@ -40,7 +40,8 @@ export function deleteFromRegistry(name) { const _decorators = {}; -export function decorateWidget(widgetName, cb) { +export function decorateWidget(decorateIdentifier, cb) { + const widgetName = decorateIdentifier.split(":")[0]; if (!_registry[widgetName]) { // eslint-disable-next-line no-console console.error( @@ -48,8 +49,8 @@ export function decorateWidget(widgetName, cb) { `decorateWidget: Could not find widget '${widgetName}' in registry` ); } - _decorators[widgetName] ??= []; - _decorators[widgetName].push(cb); + _decorators[decorateIdentifier] ??= []; + _decorators[decorateIdentifier].push(cb); } export function traverseCustomWidgets(tree, callback) {