/**
  * Returns the actual value of the selected Option.
  *
  * @return the value
  */
 @Override
 public String jsxGet_value() {
   final HtmlSelect htmlSelect = getHtmlSelect();
   final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions();
   if (selectedOptions.isEmpty()) {
     return "";
   }
   return ((HTMLOptionElement) selectedOptions.get(0).getScriptObject()).jsxGet_value();
 }
 /**
  * Returns the value of the "selectedIndex" property.
  *
  * @return the selectedIndex property
  */
 public int jsxGet_selectedIndex() {
   final HtmlSelect htmlSelect = getHtmlSelect();
   final List<HtmlOption> selectedOptions = htmlSelect.getSelectedOptions();
   if (selectedOptions.isEmpty()) {
     return -1;
   }
   final List<HtmlOption> allOptions = htmlSelect.getOptions();
   return allOptions.indexOf(selectedOptions.get(0));
 }
  /**
   * Sets the value of the "selectedIndex" property.
   *
   * @param index the new value
   */
  public void jsxSet_selectedIndex(final int index) {
    final HtmlSelect htmlSelect = getHtmlSelect();

    if (index != 0
        && getBrowserVersion()
            .hasFeature(BrowserVersionFeatures.JS_SELECT_SELECTED_INDEX_THROWS_IF_BAD)
        && (index < -1 || index >= htmlSelect.getOptionSize())) {
      throw Context.reportRuntimeError("Invalid index for select node: " + index);
    }

    for (final HtmlOption itemToUnSelect : htmlSelect.getSelectedOptions()) {
      htmlSelect.setSelectedAttribute(itemToUnSelect, false);
    }
    if (index < 0) {
      return;
    }

    final List<HtmlOption> allOptions = htmlSelect.getOptions();

    if (index < allOptions.size()) {
      final HtmlOption itemToSelect = allOptions.get(index);
      htmlSelect.setSelectedAttribute(itemToSelect, true, false);
    }
  }