Prevent the setup callback for page actions to be executed twice
authorAlexander Ebert <ebert@woltlab.com>
Tue, 8 Sep 2020 15:23:41 +0000 (17:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 8 Sep 2020 15:23:41 +0000 (17:23 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Action.js

index db018aaa6cb2833ca0cd3a7a59b617cc768f5f30..bdaf2cf674b75a8a7776e1b3959451f649a0942b 100644 (file)
@@ -32,6 +32,10 @@ define(['Dictionary', 'Language'], function (Dictionary, Language) {
                 * Initializes the page action container.
                 */
                setup: function () {
+                       if (_didInit) {
+                               return;
+                       }
+                       
                        _didInit = true;
                        
                        _wrapper = elCreate('div');
@@ -124,7 +128,7 @@ define(['Dictionary', 'Language'], function (Dictionary, Language) {
                 * @param       {string=}       insertBeforeButton      insert button before element identified by provided button name
                 */
                add: function (buttonName, button, insertBeforeButton) {
-                       if (_didInit === false) this.setup();
+                       this.setup();
                        
                        // The wrapper is required for backwards compatibility, because some implementations rely on a
                        // dedicated parent element to insert elements, for example, for drop-down menus.