Report more invalid selectors (bug 1384216).

This commit is contained in:
Josh Matthews 2017-08-28 17:21:57 -07:00
parent 9a7cceb0a1
commit 4016371e1d
2 changed files with 19 additions and 6 deletions

View file

@ -255,6 +255,7 @@ fn extract_error_params<'a>(err: ParseError<'a>) -> Option<ErrorParams<'a>> {
CssParseError::Custom(SelectorParseError::ExplicitNamespaceUnexpectedToken(t)) |
CssParseError::Custom(SelectorParseError::PseudoElementExpectedIdent(t)) |
CssParseError::Custom(SelectorParseError::NoIdentForPseudo(t)) |
CssParseError::Custom(SelectorParseError::ClassNeedsIdent(t)) |
CssParseError::Custom(SelectorParseError::PseudoElementExpectedColon(t)) =>
(None, Some(ErrorString::UnexpectedToken(t))),
@ -268,6 +269,9 @@ fn extract_error_params<'a>(err: ParseError<'a>) -> Option<ErrorParams<'a>> {
CssParseError::Custom(SelectorParseError::DanglingCombinator) =>
(None, None),
CssParseError::Custom(SelectorParseError::EmptyNegation) =>
(None, Some(ErrorString::Snippet(")".into()))),
err => match extract_error_param(err) {
Some(e) => (Some(e), None),
None => return None,
@ -368,6 +372,10 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
Some(&b"PEPseudoClassArgNotIdent\0"[..]),
CssParseError::Custom(SelectorParseError::PseudoElementExpectedIdent(_)) =>
Some(&b"PEPseudoSelBadName\0"[..]),
CssParseError::Custom(SelectorParseError::ClassNeedsIdent(_)) =>
Some(&b"PEClassSelNotIdent\0"[..]),
CssParseError::Custom(SelectorParseError::EmptyNegation) =>
Some(&b"PENegationBadArg\0"[..]),
_ => None,
};
return (prefix, b"PEBadSelectorRSIgnored\0", Action::Nothing);