mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update select shadow tree when contents of selected option change (#36958)
The label that is displayed inside a `<select>` element is that of the selected option, or it's text contents if the option does not have a label. Therefore, we need to update the `<select>` shadow tree when the contents of the selected option change. Testing: Covered by existing web platform tests Fixes https://github.com/servo/servo/issues/36926 Fixes https://github.com/servo/servo/issues/36925 --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
fec6778eaa
commit
41283220dd
5 changed files with 32 additions and 11 deletions
|
@ -29,7 +29,7 @@ use crate::dom::htmlformelement::HTMLFormElement;
|
|||
use crate::dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||
use crate::dom::htmlscriptelement::HTMLScriptElement;
|
||||
use crate::dom::htmlselectelement::HTMLSelectElement;
|
||||
use crate::dom::node::{BindContext, Node, ShadowIncluding, UnbindContext};
|
||||
use crate::dom::node::{BindContext, ChildrenMutation, Node, ShadowIncluding, UnbindContext};
|
||||
use crate::dom::text::Text;
|
||||
use crate::dom::validation::Validatable;
|
||||
use crate::dom::validitystate::ValidationFlags;
|
||||
|
@ -380,4 +380,26 @@ impl VirtualMethods for HTMLOptionElement {
|
|||
el.check_disabled_attribute();
|
||||
}
|
||||
}
|
||||
|
||||
fn children_changed(&self, mutation: &ChildrenMutation) {
|
||||
if let Some(super_type) = self.super_type() {
|
||||
super_type.children_changed(mutation);
|
||||
}
|
||||
|
||||
// Changing the descendants of a selected option can change it's displayed label
|
||||
// if it does not have a label attribute
|
||||
if !self
|
||||
.upcast::<Element>()
|
||||
.has_attribute(&local_name!("label"))
|
||||
{
|
||||
if let Some(owner_select) = self.owner_select_element() {
|
||||
if owner_select
|
||||
.selected_option()
|
||||
.is_some_and(|selected_option| self == &*selected_option)
|
||||
{
|
||||
owner_select.update_shadow_tree(CanGc::note());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue