~nicolaskempf57/select-a11y

0a367de74d72b424426bd1bb5f8906bee5748010 — Nicolas KEMPF 4 months ago a4f2d9b
fix: check option exists before using it
1 files changed, 4 insertions(+), 4 deletions(-)

M src/select-a11y.js
M src/select-a11y.js => src/select-a11y.js +4 -4
@@ 524,16 524,16 @@ class Select {
      this.el.selectedIndex = optionIndex;
    }
    this.el.dispatchEvent(new Event('change'));
    this.suggestions.forEach(function(suggestion){
    this.suggestions.forEach((suggestion) => {
      const index = parseInt(suggestion.getAttribute('data-index'), 10);

      if(this.el.item(index).selected){
      const option = this.el.item(index);
      if(option && option.selected) {
        suggestion.setAttribute('aria-selected', 'true');
      }
      else{
        suggestion.removeAttribute('aria-selected');
      }
    }.bind(this));
    });

    this._setButtonText();
    if(this.multiple && this._options.showSelected) {