From 047d133674776471ab58bf1a004d3b255850fd64 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 9 Jan 2017 18:07:57 +0100 Subject: [PATCH] UiItemList was only partially destructed --- .../files/js/WoltLabSuite/Core/Ui/ItemList.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js index 5a7c0811ae..53b5f90201 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/ItemList.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @module WoltLabSuite/Core/Ui/ItemList */ -define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSuite/Core/Ui/Suggestion'], function(Core, Dictionary, Language, DomTraverse, EventKey, UiSuggestion) { +define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSuite/Core/Ui/Suggestion', 'Ui/SimpleDropdown'], function(Core, Dictionary, Language, DomTraverse, EventKey, UiSuggestion, UiSimpleDropdown) { "use strict"; var _activeId = ''; @@ -38,6 +38,23 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'EventKey', 'WoltLabSu throw new Error("Expected a valid element id, '" + elementId + "' is invalid."); } + // remove data from previous instance + if (_data.has(elementId)) { + var tmp = _data.get(elementId); + + for (var key in tmp) { + if (tmp.hasOwnProperty(key)) { + var el = tmp[key]; + if (el instanceof Element && el.parentNode) { + elRemove(el); + } + } + } + + UiSimpleDropdown.destroy(elementId); + _data.delete(elementId); + } + options = Core.extend({ // search parameters for suggestions ajax: { -- 2.20.1