examples/dropdown/dist/index.js
function syncUI(customSelect, defaultValue, isMultiple) {
    var _this2 = this;

    console.log(defaultValue, isMultiple);
    var menuItems = this.getMenuItems(customSelect);
    var tglBtn = this.getToggleBtn(customSelect);
    var hasSelected = false;
    [].forEach.call(menuItems, function (menuItem) {
      if (defaultValue !== '') {
        var value = _this2.getItemValue(menuItem);
        if (isMultiple) {
          for (var k = 0; k < defaultValue.length; k++) {
            if (defaultValue[k] == value) {
              _this2.setItemActive(menuItem);
              hasSelected = true;
              _this2.getOptionByValue(customSelect, value).selected = true;
              break;
            }
          }
        } else if (value == defaultValue) {
          _this2.setItemActive(menuItem);
          hasSelected = true;
          _this2.getOptionByValue(customSelect, value).selected = true;
          if (tglBtn.innerHTML === '') {
            tglBtn.innerHTML = menuItem.innerHTML;
          }
        }
      } else if (menuItem.hasAttribute('aria-selected')) {
        _this2.setItemActive(menuItem);
        hasSelected = true;
        if (tglBtn.innerHTML === '') {
          tglBtn.innerHTML = menuItem.innerHTML;
        }
      } else if (menuItem.classList.contains(_this2.Config.classNameActive)) {
        _this2.setItemInactive(menuItem);
      }
    });

    if (!hasSelected) {
      this.setItemActive(menuItems[0]);
      this.getHiddenSelect(customSelect).options[0].setAttribute('selected', '');
      if (tglBtn.innerHTML === '') {
        tglBtn.innerHTML = menuItems[0].innerHTML;
      }
    }
  }
function syncUI(customSelect, defaultValue, isMultiple) {
    var _this2 = this;

    console.log(defaultValue, isMultiple);
    var menuItems = this.getMenuItems(customSelect);
    var tglBtn = this.getToggleBtn(customSelect);
    var hasSelected = false;
    [].forEach.call(menuItems, function (menuItem) {
      if (defaultValue !== '') {
        var value = _this2.getItemValue(menuItem);
        if (isMultiple) {
          for (var k = 0; k < defaultValue.length; k++) {
            if (defaultValue[k] == value) {
              _this2.setItemActive(menuItem);
              hasSelected = true;
              _this2.getOptionByValue(customSelect, value).selected = true;
              break;
            }
          }
        } else if (value == defaultValue) {
          _this2.setItemActive(menuItem);
          hasSelected = true;
          _this2.getOptionByValue(customSelect, value).selected = true;
          if (tglBtn.innerHTML === '') {
            tglBtn.innerHTML = menuItem.innerHTML;
          }
        }
      } else if (menuItem.hasAttribute('aria-selected')) {
        _this2.setItemActive(menuItem);
        hasSelected = true;
        if (tglBtn.innerHTML === '') {
          tglBtn.innerHTML = menuItem.innerHTML;
        }
      } else if (menuItem.classList.contains(_this2.Config.classNameActive)) {
        _this2.setItemInactive(menuItem);
      }
    });

    if (!hasSelected) {
      this.setItemActive(menuItems[0]);
      this.getHiddenSelect(customSelect).options[0].setAttribute('selected', '');
      if (tglBtn.innerHTML === '') {
        tglBtn.innerHTML = menuItems[0].innerHTML;
      }
    }
  }
function syncUI ( customSelect , defaultValue , isMultiple ) { var _this2 = this ; console . log ( defaultValue , isMultiple ) ; var menuItems = this . getMenuItems ( customSelect ) ; var tglBtn = this . getToggleBtn ( customSelect ) ; var hasSelected = false ; [ ] . forEach . call ( menuItems , function ( menuItem ) { if ( defaultValue !== '' ) { var value = _this2 . getItemValue ( menuItem ) ; if ( isMultiple ) { for ( var k = 0 ; k < defaultValue . length ; k ++ ) { if ( defaultValue [ k ] == value ) { _this2 . setItemActive ( menuItem ) ; hasSelected = true ; _this2 . getOptionByValue ( customSelect , value ) . selected = true ; break ; } } } else if ( value == defaultValue ) { _this2 . setItemActive ( menuItem ) ; hasSelected = true ; _this2 . getOptionByValue ( customSelect , value ) . selected = true ; if ( tglBtn . innerHTML === '' ) { tglBtn . innerHTML = menuItem . innerHTML ; } } } else if ( menuItem . hasAttribute ( 'aria-selected' ) ) { _this2 . setItemActive ( menuItem ) ; hasSelected = true ; if ( tglBtn . innerHTML === '' ) { tglBtn . innerHTML = menuItem . innerHTML ; } } else if ( menuItem . classList . contains ( _this2 . Config . classNameActive ) ) { _this2 . setItemInactive ( menuItem ) ; } } ) ; if ( ! hasSelected ) { this . setItemActive ( menuItems [ 0 ] ) ; this . getHiddenSelect ( customSelect ) . options [ 0 ] . setAttribute ( 'selected' , '' ) ; if ( tglBtn . innerHTML === '' ) { tglBtn . innerHTML = menuItems [ 0 ] . innerHTML ; } } }
Synchronizes default value and selected options with UI
If dropdown item has aria-selected but has no active class, add it
If dropdown item has no aria-selected but has active class, remove it
If no dropdown item selected, select 1st item and hidden option
If customselect has value attribute, sets selected option according to it in highest priority

@param {HTMLElement} customSelect
@param {String|Array} defaultValue
@param {boolean} isMultiple
Synchronizes default value and selected options with UI If dropdown item has aria - selected but has no active class add it If dropdown item has no aria - selected but has active class remove it If no dropdown item selected select 1st item and hidden option If customselect has value attribute sets selected option according to it in highest priority