зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #13762 - Implement "reset algorithm" for `<select>` (from frewsxcv:select-reset); r=Manishearth
Source-Repo: https://github.com/servo/servo Source-Revision: 28be83bd9a5b2adc136bfdf006ae5d285d0178ad
This commit is contained in:
Родитель
e65ee3c0ea
Коммит
d1762526f5
|
@ -634,8 +634,7 @@ impl HTMLFormElement {
|
|||
// {}
|
||||
//}
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLSelectElement)) => {
|
||||
// Unimplemented
|
||||
{}
|
||||
child.downcast::<HTMLSelectElement>().unwrap().reset();
|
||||
}
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLTextAreaElement)) => {
|
||||
child.downcast::<HTMLTextAreaElement>().unwrap().reset();
|
||||
|
|
|
@ -84,6 +84,16 @@ impl HTMLSelectElement {
|
|||
HTMLSelectElementBinding::Wrap)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#the-select-element:concept-form-reset-control
|
||||
pub fn reset(&self) {
|
||||
let node = self.upcast::<Node>();
|
||||
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
|
||||
opt.set_selectedness(opt.DefaultSelected());
|
||||
opt.set_dirtiness(false);
|
||||
}
|
||||
self.ask_for_reset();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#ask-for-a-reset
|
||||
pub fn ask_for_reset(&self) {
|
||||
if self.Multiple() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче