aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r--components/script/dom/htmlelement.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 34a7847187a..b04082eae4d 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -296,6 +296,26 @@ impl HTMLElement {
let local_name = Atom::from_slice(&to_snake_case(local_name));
self.upcast::<Element>().remove_attribute(&ns!(""), &local_name);
}
+
+ // https://html.spec.whatwg.org/multipage/#category-label
+ pub fn is_labelable_element(&self) -> bool {
+ // Note: HTMLKeygenElement is omitted because Servo doesn't currently implement it
+ match self.upcast::<Node>().type_id() {
+ NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) =>
+ match type_id {
+ HTMLElementTypeId::HTMLInputElement =>
+ self.downcast::<HTMLInputElement>().unwrap().Type() != "hidden",
+ HTMLElementTypeId::HTMLButtonElement |
+ HTMLElementTypeId::HTMLMeterElement |
+ HTMLElementTypeId::HTMLOutputElement |
+ HTMLElementTypeId::HTMLProgressElement |
+ HTMLElementTypeId::HTMLSelectElement |
+ HTMLElementTypeId::HTMLTextAreaElement => true,
+ _ => false,
+ },
+ _ => false,
+ }
+ }
}
impl VirtualMethods for HTMLElement {