From fe0a4c3f82fb9f991394a0efed8f2b997be5291c Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 16 Jun 2017 11:18:17 +0200 Subject: [PATCH] Improved emptyElem function --- assets/js/common/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index 0458e532..9f985ce7 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -39,14 +39,18 @@ function byId(nodeName){ */ function emptyElem(container){ //Get children references - var children = container.childNodes; + var children = container.children; //Process each child - for(i in children){ - if(children[i].remove) - children[i].remove(); - } + while(container.children.length > 0){ + //Check if the child has subchild + if(container.children[0].children) + emptyElem(container.children[0]); //Remove them first + + //Remove child + container.children[0].remove(); + } //Success return true;