style: Clear last_parsed_property_id right after successfully parsing the value.

Rather than waiting until parsing another id (successfully or
unsuccessfully).

If we error before we even get to PropertyId::parse, we'd incorrectly
associate the error with the wrong property, incorrectly omitting it
sometimes.

Differential Revision: https://phabricator.services.mozilla.com/D78260
This commit is contained in:
Emilio Cobos Álvarez 2020-06-05 18:13:14 +00:00
parent 685e749cfc
commit 3884328ce3
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A

View file

@ -1347,7 +1347,6 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b> {
let id = match PropertyId::parse(&name, self.context) {
Ok(id) => id,
Err(..) => {
self.last_parsed_property_id = None;
return Err(input.new_custom_error(StyleParseErrorKind::UnknownProperty(name)));
},
};
@ -1469,6 +1468,10 @@ pub fn parse_property_declaration_list(
match declaration {
Ok(importance) => {
block.extend(iter.parser.declarations.drain(), importance);
// We've successfully parsed a declaration, so forget about
// `last_parsed_property_id`. It'd be wrong to associate any
// following error with this property.
iter.parser.last_parsed_property_id = None;
},
Err((error, slice)) => {
iter.parser.declarations.clear();