Harden UiSimpleDropdown.destroy() against changed DOM
authorMatthias Schmidt <gravatronics@live.com>
Mon, 22 Aug 2016 15:37:39 +0000 (17:37 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 22 Aug 2016 15:37:42 +0000 (17:37 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js

index 2bd4c4f88a6549d5dd418c50edf53d37ee7e25ed..0eb78196721b9f2f56be34c8c61428d3a98cc84f 100644 (file)
@@ -281,10 +281,15 @@ define(
                                return false;
                        }
                        
-                       this.close(containerId);
-                       
-                       var menu = _menus.get(containerId);
-                       _menus.parentNode.removeChild(menu);
+                       try {
+                               this.close(containerId);
+                               
+                               var menu = _menus.get(containerId);
+                               _menus.parentNode.removeChild(menu);
+                       }
+                       catch (e) {
+                               // the elements might not exist anymore thus ignore all errors cleaning up
+                       }
                        
                        _menus['delete'](containerId);
                        _dropdowns['delete'](containerId);