From 10cd0e55313062229aa654af1130433292c1821e Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 19 Oct 2023 23:26:30 +0100 Subject: [PATCH] DEV: Print error when decorateWidget target does not exist (#24026) --- app/assets/javascripts/discourse/app/widgets/widget.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/widgets/widget.js b/app/assets/javascripts/discourse/app/widgets/widget.js index 5d398aced5e..b4b6d580c1f 100644 --- a/app/assets/javascripts/discourse/app/widgets/widget.js +++ b/app/assets/javascripts/discourse/app/widgets/widget.js @@ -41,7 +41,14 @@ export function deleteFromRegistry(name) { const _decorators = {}; export function decorateWidget(widgetName, cb) { - _decorators[widgetName] = _decorators[widgetName] || []; + if (!_registry[name]) { + // eslint-disable-next-line no-console + console.error( + consolePrefix(), + `decorateWidget: Could not find widget '${name}' in registry` + ); + } + _decorators[widgetName] ??= []; _decorators[widgetName].push(cb); }