mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implement 'control' attribute for <label> elements
This commit is contained in:
parent
3b50f21963
commit
f97d1d148b
8 changed files with 74 additions and 60 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue