aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlelement.rs
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-01-08 20:56:49 -0500
committerCorey Farwell <coreyf@rwell.org>2016-01-09 13:22:15 -0500
commite3728f616747325201bac468d5ddbd8973d02b74 (patch)
treec582d6a94dfb441fc74683def3ef3117c98b8962 /components/script/dom/htmlelement.rs
parent083d3e0201772918d040a6eb12e87c03fd443587 (diff)
downloadservo-e3728f616747325201bac468d5ddbd8973d02b74.tar.gz
servo-e3728f616747325201bac468d5ddbd8973d02b74.zip
Refactor 'listed element' logic for HTMLFieldSetElement::Elements
`HTMLElement::is_listed_element` method was added, which matches the `HTMLElement::is_labelable_element` method directly above
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r--components/script/dom/htmlelement.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index d0f3f35d0ab..8c718c5ab29 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -354,6 +354,30 @@ impl HTMLElement {
}
}
+ // https://html.spec.whatwg.org/multipage/#category-listed
+ pub fn is_listed_element(&self) -> bool {
+ // Servo does not implement HTMLKeygenElement
+ // https://github.com/servo/servo/issues/2782
+ if self.upcast::<Element>().local_name() == &atom!("keygen") {
+ return true;
+ }
+
+ match self.upcast::<Node>().type_id() {
+ NodeTypeId::Element(ElementTypeId::HTMLElement(type_id)) =>
+ match type_id {
+ HTMLElementTypeId::HTMLButtonElement |
+ HTMLElementTypeId::HTMLFieldSetElement |
+ HTMLElementTypeId::HTMLInputElement |
+ HTMLElementTypeId::HTMLObjectElement |
+ HTMLElementTypeId::HTMLOutputElement |
+ HTMLElementTypeId::HTMLSelectElement |
+ HTMLElementTypeId::HTMLTextAreaElement => true,
+ _ => false,
+ },
+ _ => false,
+ }
+ }
+
pub fn supported_prop_names_custom_attr(&self) -> Vec<DOMString> {
let element = self.upcast::<Element>();
element.attrs().iter().filter_map(|attr| {