Skip to content

Commit

Permalink
Suppress UnsupportedPseudoClassOrElement warning if name starts w…
Browse files Browse the repository at this point in the history
…ith `"-"` (#266)
  • Loading branch information
pfroud authored Sep 2, 2022
1 parent d029a83 commit 1f4a7bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ impl<'a, 'o, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'o,
"window-inactive" => WebKitScrollbar(WebKitScrollbarPseudoClass::WindowInactive),

_ => {
self.options.warn(loc.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
if !name.starts_with("-") {
self.options.warn(loc.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
}
Custom(name.into())
}
};
Expand All @@ -217,7 +219,9 @@ impl<'a, 'o, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'o,
"local" if self.options.css_modules.is_some() => Local(Box::new(parcel_selectors::parser::Selector::parse(self, parser)?)),
"global" if self.options.css_modules.is_some() => Global(Box::new(parcel_selectors::parser::Selector::parse(self, parser)?)),
_ => {
self.options.warn(parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
if !name.starts_with("-") {
self.options.warn(parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
}
CustomFunction(name.into(), TokenList::parse(parser, &self.options, 0)?)
},
};
Expand Down Expand Up @@ -268,7 +272,9 @@ impl<'a, 'o, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'o,
"-webkit-resizer" => WebKitScrollbar(WebKitScrollbarPseudoElement::Resizer),

_ => {
self.options.warn(loc.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
if !name.starts_with("-") {
self.options.warn(loc.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
}
Custom(name.into())
}
};
Expand All @@ -286,7 +292,9 @@ impl<'a, 'o, 'i> parcel_selectors::parser::Parser<'i> for SelectorParser<'a, 'o,
"cue" => CueFunction(Box::new(Selector::parse(self, arguments)?)),
"cue-region" => CueRegionFunction(Box::new(Selector::parse(self, arguments)?)),
_ => {
self.options.warn(arguments.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
if !name.starts_with("-") {
self.options.warn(arguments.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())));
}
CustomFunction(name.into(), TokenList::parse(arguments, &self.options, 0)?)
}
};
Expand Down

0 comments on commit 1f4a7bb

Please sign in to comment.