зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1886377 - Fix substring attribute selectors for Servo. r=emilio
Substring attribute selectors should never match when an empty string is provided. This fixes [attr^=""], [attr$=""], [attr*=""] and [attr~=""] in Servo, which broke when D180529 removed never_matches. Gecko doesn't use this code at all, so no change in behavior. Differential Revision: https://phabricator.services.mozilla.com/D205187
This commit is contained in:
Родитель
f315309bdc
Коммит
c9d0da9645
|
@ -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))
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче