// importing addEvent function
const addEvent = require('./events').addEvent;

// main variables
let _searchWrap   = document.querySelector('div.search-container');
let _searchInput  = _searchWrap.querySelector('input.search-input');
let _searchIcon   = _searchWrap.querySelector('i.clear-search-input');
let _searchList   = _searchWrap.querySelector('ul.search-results-list');

// remove childs from body function
let removeChilds = (elemToRemove, clearValue) => {
  while(elemToRemove.firstChild) {
    elemToRemove.removeChild(elemToRemove.firstChild);
  }
  if (clearValue) {
    clearValue.value = '';
  }
};

let remove_searchList = () => {
  removeChilds(_searchList, _searchInput);
}

addEvent(_searchIcon, 'click', remove_searchList);

@@ -459,16 +459,59 @@
 e) =%3E %7B%0A
+  // removing childs while there is childs%0A
   while(
@@ -533,24 +533,24 @@
 rstChild) %7B%0A
-
     elemToRe
@@ -596,16 +596,65 @@
 d);%0A  %7D%0A
+  // if there any field that needs to be cleared%0A
   if (cl
@@ -700,16 +700,55 @@
   %7D%0A%7D;%0A%0A
+// defining remove_searchList function%0A
 let remo
@@ -817,16 +817,36 @@
 ut);%0A%7D%0A%0A
+// calling function%0A
 addEvent

add comments