diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:34:42 +0000 |
commit | da4c7e7ed675c3bf405668739c3012d140856109 (patch) | |
tree | cdd868dba063fecba609a1d819de271f0d51b23e /servo/components/selectors/attr.rs | |
parent | Adding upstream version 125.0.3. (diff) | |
download | firefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip |
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/selectors/attr.rs')
-rw-r--r-- | servo/components/selectors/attr.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/servo/components/selectors/attr.rs b/servo/components/selectors/attr.rs index fee2962237..70a0c5ea95 100644 --- a/servo/components/selectors/attr.rs +++ b/servo/components/selectors/attr.rs @@ -111,16 +111,21 @@ impl AttrSelectorOperator { let case = case_sensitivity; match self { AttrSelectorOperator::Equal => case.eq(e, s), - AttrSelectorOperator::Prefix => e.len() >= s.len() && case.eq(&e[..s.len()], s), + AttrSelectorOperator::Prefix => { + !s.is_empty() && e.len() >= s.len() && case.eq(&e[..s.len()], s) + }, AttrSelectorOperator::Suffix => { - e.len() >= s.len() && case.eq(&e[(e.len() - s.len())..], s) + !s.is_empty() && e.len() >= s.len() && case.eq(&e[(e.len() - s.len())..], s) }, AttrSelectorOperator::Substring => { - case.contains(element_attr_value, attr_selector_value) + !s.is_empty() && case.contains(element_attr_value, attr_selector_value) + }, + AttrSelectorOperator::Includes => { + !s.is_empty() && + element_attr_value + .split(SELECTOR_WHITESPACE) + .any(|part| case.eq(part.as_bytes(), s)) }, - AttrSelectorOperator::Includes => element_attr_value - .split(SELECTOR_WHITESPACE) - .any(|part| case.eq(part.as_bytes(), s)), AttrSelectorOperator::DashMatch => { case.eq(e, s) || (e.get(s.len()) == Some(&b'-') && case.eq(&e[..s.len()], s)) }, |