style: Disallow forgiving selector-parsing in @supports

As per spec, see https://github.com/w3c/csswg-drafts/issues/7280

Differential Revision: https://phabricator.services.mozilla.com/D156468
This commit is contained in:
Emilio Cobos Álvarez 2022-09-06 17:00:33 +00:00 committed by Martin Robinson
parent ab36c8a39b
commit 9f6341b83a
6 changed files with 25 additions and 23 deletions

View file

@ -276,6 +276,11 @@ pub trait Parser<'i> {
false
}
/// Whether to allow forgiving selector-list parsing.
fn allow_forgiving_selectors(&self) -> bool {
true
}
/// Parses non-tree-structural pseudo-classes. Tree structural pseudo-classes,
/// like `:first-child`, are built into this library.
///
@ -400,7 +405,11 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
Ok(selector) => values.push(selector),
Err(err) => match recovery {
ParseErrorRecovery::DiscardList => return Err(err),
ParseErrorRecovery::IgnoreInvalidSelector => {},
ParseErrorRecovery::IgnoreInvalidSelector => {
if !parser.allow_forgiving_selectors() {
return Err(err);
}
},
},
}