From 7e504a148955a2057ed50c7cb5d7bca437550eee Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 28 Nov 2022 18:14:35 +0000 Subject: [PATCH] DEV: Only patch bootbox methods once in tests (#19222) We were re-patching the deprecated bootbox methods during every app initialization, which would lead to hundreds of deprecation messages being printed for a single invocation. --- .../discourse/app/initializers/jquery-plugins.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/javascripts/discourse/app/initializers/jquery-plugins.js b/app/assets/javascripts/discourse/app/initializers/jquery-plugins.js index e9844f8dee..8302cf90bb 100644 --- a/app/assets/javascripts/discourse/app/initializers/jquery-plugins.js +++ b/app/assets/javascripts/discourse/app/initializers/jquery-plugins.js @@ -3,9 +3,15 @@ import bootbox from "bootbox"; import { getOwner } from "discourse-common/lib/get-owner"; import deprecated from "discourse-common/lib/deprecated"; +let jqueryPluginsConfigured = false; + export default { name: "jquery-plugins", initialize() { + if (jqueryPluginsConfigured) { + return; + } + // Settings for bootbox bootbox.animate(false); bootbox.backdrop(true); @@ -46,5 +52,7 @@ export default { // Initialize the autocomplete tool $.fn.autocomplete = autocomplete; + + jqueryPluginsConfigured = true; }, };