Added the condition to removeItems, that the to be removedItem be direct child of the menus HTML element.
Change-Id: Ife934e340ab30ed5d497a40659e6a48f8d3922ff
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 088618b..3575c7c 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -622,10 +622,15 @@
* Delete all visible items from the menu element
*/
- removeItems : function () {
+ removeItems : function () {
const liElements=this._el.getElementsByTagName("LI");
- while (liElements.length>0){
- this._el.removeChild(liElements[0]);
+ var ignoredCount = 0; //counts how many LI tag elements are not actually direct children
+ while (liElements.length>ignoredCount) {
+ if (liElements[ignoredCount].parentNode === this._el){
+ this._el.removeChild(liElements[ignoredCount]);
+ } else {
+ ignoredCount++;
+ }
};
},