diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs
index db1ec1084d7..67abe7a49e4 100644
--- a/components/script/dom/htmloptgroupelement.rs
+++ b/components/script/dom/htmloptgroupelement.rs
@@ -5,10 +5,12 @@
use dom_struct::dom_struct;
use html5ever::{LocalName, Prefix, local_name};
use js::rust::HandleObject;
+use script_bindings::str::DOMString;
use stylo_dom::ElementState;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::HTMLOptGroupElementBinding::HTMLOptGroupElementMethods;
+use crate::dom::bindings::codegen::GenericBindings::NodeBinding::Node_Binding::NodeMethods;
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::root::DomRoot;
use crate::dom::document::Document;
@@ -16,12 +18,13 @@ use crate::dom::element::{AttributeMutation, Element};
use crate::dom::htmlelement::HTMLElement;
use crate::dom::htmloptionelement::HTMLOptionElement;
use crate::dom::htmlselectelement::HTMLSelectElement;
-use crate::dom::node::{BindContext, Node, ShadowIncluding, UnbindContext};
+use crate::dom::node::{BindContext, Node, UnbindContext};
use crate::dom::validation::Validatable;
use crate::dom::validitystate::ValidationFlags;
use crate::dom::virtualmethods::VirtualMethods;
use crate::script_runtime::CanGc;
+///
#[dom_struct]
pub(crate) struct HTMLOptGroupElement {
htmlelement: HTMLElement,
@@ -62,17 +65,18 @@ impl HTMLOptGroupElement {
}
fn update_select_validity(&self) {
- if let Some(select) = self
- .upcast::()
- .ancestors()
- .filter_map(DomRoot::downcast::)
- .next()
- {
+ if let Some(select) = self.owner_select_element() {
select
.validity_state()
.perform_validation_and_update(ValidationFlags::all());
}
}
+
+ fn owner_select_element(&self) -> Option> {
+ self.upcast::()
+ .GetParentNode()
+ .and_then(DomRoot::downcast)
+ }
}
impl HTMLOptGroupElementMethods for HTMLOptGroupElement {
@@ -81,6 +85,12 @@ impl HTMLOptGroupElementMethods for HTMLOptGroupElement {
// https://html.spec.whatwg.org/multipage/#dom-optgroup-disabled
make_bool_setter!(SetDisabled, "disabled");
+
+ // https://html.spec.whatwg.org/multipage/#dom-optgroup-label
+ make_getter!(Label, "label");
+
+ // https://html.spec.whatwg.org/multipage/#dom-optgroup-label
+ make_setter!(SetLabel, "label");
}
impl VirtualMethods for HTMLOptGroupElement {
@@ -133,12 +143,7 @@ impl VirtualMethods for HTMLOptGroupElement {
fn unbind_from_tree(&self, context: &UnbindContext) {
self.super_type().unwrap().unbind_from_tree(context);
- if let Some(select) = context
- .parent
- .inclusive_ancestors(ShadowIncluding::No)
- .filter_map(DomRoot::downcast::)
- .next()
- {
+ if let Some(select) = context.parent.downcast::() {
select
.validity_state()
.perform_validation_and_update(ValidationFlags::all());
diff --git a/components/script_bindings/webidls/HTMLOptGroupElement.webidl b/components/script_bindings/webidls/HTMLOptGroupElement.webidl
index afa11148cd5..fc72ce2684a 100644
--- a/components/script_bindings/webidls/HTMLOptGroupElement.webidl
+++ b/components/script_bindings/webidls/HTMLOptGroupElement.webidl
@@ -9,6 +9,6 @@ interface HTMLOptGroupElement : HTMLElement {
[CEReactions]
attribute boolean disabled;
- // [CEReactions]
- // attribute DOMString label;
+ [CEReactions]
+ attribute DOMString label;
};
diff --git a/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLOptGroupElement.html.ini b/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLOptGroupElement.html.ini
deleted file mode 100644
index 34a31a796a8..00000000000
--- a/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLOptGroupElement.html.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[HTMLOptGroupElement.html]
- [label on HTMLOptGroupElement must enqueue an attributeChanged reaction when adding a new attribute]
- expected: FAIL
-
- [label on HTMLOptGroupElement must enqueue an attributeChanged reaction when replacing an existing attribute]
- expected: FAIL
diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini
index 5a18c8cc65e..0ee42474317 100644
--- a/tests/wpt/meta/html/dom/idlharness.https.html.ini
+++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini
@@ -7765,12 +7765,6 @@
[HTMLSelectElement interface: document.createElement("select") must inherit property "showPicker()" with the proper type]
expected: FAIL
- [HTMLOptGroupElement interface: attribute label]
- expected: FAIL
-
- [HTMLOptGroupElement interface: document.createElement("optgroup") must inherit property "label" with the proper type]
- expected: FAIL
-
[HTMLTextAreaElement interface: attribute autocomplete]
expected: FAIL
diff --git a/tests/wpt/meta/html/dom/reflection-forms.html.ini b/tests/wpt/meta/html/dom/reflection-forms.html.ini
index dc44db86f7e..ed2239e31fc 100644
--- a/tests/wpt/meta/html/dom/reflection-forms.html.ini
+++ b/tests/wpt/meta/html/dom/reflection-forms.html.ini
@@ -2237,120 +2237,6 @@
[optgroup.tabIndex: IDL set to -2147483648]
expected: FAIL
- [optgroup.label: typeof IDL attribute]
- expected: FAIL
-
- [optgroup.label: IDL get with DOM attribute unset]
- expected: FAIL
-
- [optgroup.label: setAttribute() to ""]
- expected: FAIL
-
- [optgroup.label: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
- expected: FAIL
-
- [optgroup.label: setAttribute() to undefined]
- expected: FAIL
-
- [optgroup.label: setAttribute() to 7]
- expected: FAIL
-
- [optgroup.label: setAttribute() to 1.5]
- expected: FAIL
-
- [optgroup.label: setAttribute() to "5%"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to "+100"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to ".5"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to true]
- expected: FAIL
-
- [optgroup.label: setAttribute() to false]
- expected: FAIL
-
- [optgroup.label: setAttribute() to object "[object Object\]"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to NaN]
- expected: FAIL
-
- [optgroup.label: setAttribute() to Infinity]
- expected: FAIL
-
- [optgroup.label: setAttribute() to -Infinity]
- expected: FAIL
-
- [optgroup.label: setAttribute() to "\\0"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to null]
- expected: FAIL
-
- [optgroup.label: setAttribute() to object "test-toString"]
- expected: FAIL
-
- [optgroup.label: setAttribute() to object "test-valueOf"]
- expected: FAIL
-
- [optgroup.label: IDL set to ""]
- expected: FAIL
-
- [optgroup.label: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "]
- expected: FAIL
-
- [optgroup.label: IDL set to undefined]
- expected: FAIL
-
- [optgroup.label: IDL set to 7]
- expected: FAIL
-
- [optgroup.label: IDL set to 1.5]
- expected: FAIL
-
- [optgroup.label: IDL set to "5%"]
- expected: FAIL
-
- [optgroup.label: IDL set to "+100"]
- expected: FAIL
-
- [optgroup.label: IDL set to ".5"]
- expected: FAIL
-
- [optgroup.label: IDL set to true]
- expected: FAIL
-
- [optgroup.label: IDL set to false]
- expected: FAIL
-
- [optgroup.label: IDL set to object "[object Object\]"]
- expected: FAIL
-
- [optgroup.label: IDL set to NaN]
- expected: FAIL
-
- [optgroup.label: IDL set to Infinity]
- expected: FAIL
-
- [optgroup.label: IDL set to -Infinity]
- expected: FAIL
-
- [optgroup.label: IDL set to "\\0"]
- expected: FAIL
-
- [optgroup.label: IDL set to null]
- expected: FAIL
-
- [optgroup.label: IDL set to object "test-toString"]
- expected: FAIL
-
- [optgroup.label: IDL set to object "test-valueOf"]
- expected: FAIL
-
[option.accessKey: typeof IDL attribute]
expected: FAIL