Files
sdk/tools/dom/templates/html/impl/impl_HTMLSelectElement.darttemplate
T
Graciliano Monteiro Passos 5d18799eae HTMLSelectElement: fix selectedOptions when selectedIndex < 0
Closes https://github.com/dart-lang/sdk/pull/54618

Also adds a comment to go.sh mentioning vpython3 comes with
depot_tools.

GitOrigin-RevId: 5e057703067c24d9d41bac75b6251c8f3a2fddd3
Change-Id: I937d8618c24602b4c0844d8a52ff00095836bca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346220
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-01-22 20:15:26 +00:00

28 lines
992 B
Plaintext

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of $LIBRARYNAME;
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS {
$!MEMBERS
// Override default options, since IE returns SelectElement itself and it
// does not operate as a List.
List<OptionElement> get options {
dynamic options = this.querySelectorAll<OptionElement>('option');
return new UnmodifiableListView(options.toList());
}
List<OptionElement> get selectedOptions {
// IE does not change the selected flag for single-selection items.
if (this.multiple$NULLASSERT) {
var options = this.options.where((o) => o.selected).toList();
return new UnmodifiableListView(options);
} else {
var i = this.selectedIndex$NULLASSERT;
return i < 0 ? [] : [this.options[i]];
}
}
}