aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/element.rs
diff options
context:
space:
mode:
authoreri <eri@inventati.org>2024-03-30 11:06:26 +0100
committerGitHub <noreply@github.com>2024-03-30 10:06:26 +0000
commite3d6b66d5fa0d6b076012d282012264906e55ea6 (patch)
tree065a03cb3cb717d929741ccce30a5cc7a1df3d8f /components/script/dom/element.rs
parent92d9081366d12e79f84353cfa5e6500e3d586d6f (diff)
downloadservo-e3d6b66d5fa0d6b076012d282012264906e55ea6.tar.gz
servo-e3d6b66d5fa0d6b076012d282012264906e55ea6.zip
clippy: Fix `match_like_matches` warnings (#31947)
* clippy: Fix `match_like_matches` warnings * Fix link to custom element state in specification. --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/script/dom/element.rs')
-rw-r--r--components/script/dom/element.rs40
1 files changed, 16 insertions, 24 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index c86cb2e0a9f..f4e9b16d2f1 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -345,16 +345,17 @@ impl Element {
self.is.borrow().clone()
}
+ /// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
pub fn set_custom_element_state(&self, state: CustomElementState) {
// no need to inflate rare data for uncustomized
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
self.ensure_rare_data().custom_element_state = state;
}
- // https://dom.spec.whatwg.org/#concept-element-defined
- let in_defined_state = match state {
- CustomElementState::Uncustomized | CustomElementState::Custom => true,
- _ => false,
- };
+
+ let in_defined_state = matches!(
+ state,
+ CustomElementState::Uncustomized | CustomElementState::Custom
+ );
self.set_state(ElementState::DEFINED, in_defined_state)
}
@@ -1393,21 +1394,18 @@ impl Element {
}
// <a>, <input>, <select>, and <textrea> are inherently focusable.
- match node.type_id() {
+ matches!(
+ node.type_id(),
NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLAnchorElement,
- )) |
- NodeTypeId::Element(ElementTypeId::HTMLElement(
+ )) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLInputElement,
- )) |
- NodeTypeId::Element(ElementTypeId::HTMLElement(
+ )) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLSelectElement,
- )) |
- NodeTypeId::Element(ElementTypeId::HTMLElement(
+ )) | NodeTypeId::Element(ElementTypeId::HTMLElement(
HTMLElementTypeId::HTMLTextAreaElement,
- )) => true,
- _ => false,
- }
+ ))
+ )
}
pub fn is_actually_disabled(&self) -> bool {
@@ -1493,7 +1491,7 @@ impl Element {
.map(|js| DomRoot::from_ref(&**js))
}
- // https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
+ /// <https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name>
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
let name = &self.parsed_name(name);
let maybe_attribute = self
@@ -1506,10 +1504,7 @@ impl Element {
if *name == local_name!("id") || *name == local_name!("name") {
match maybe_attr {
None => true,
- Some(ref attr) => match *attr.value() {
- AttrValue::Atom(_) => true,
- _ => false,
- },
+ Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
}
} else {
true
@@ -2932,10 +2927,7 @@ impl VirtualMethods for Element {
//
// Juggle a bit to keep the borrow checker happy
// while avoiding the extra clone.
- let is_declaration = match *attr.value() {
- AttrValue::Declaration(..) => true,
- _ => false,
- };
+ let is_declaration = matches!(*attr.value(), AttrValue::Declaration(..));
let block = if is_declaration {
let mut value = AttrValue::String(String::new());