Fix issue when using <optgroup> elements in <select>