stylo: Don't error out on trailing whitespace in attr()

This commit is contained in:
Manish Goregaokar 2017-09-26 13:40:22 -07:00 committed by Manish Goregaokar
parent 68533ac46b
commit 2e1359b164

View file

@ -740,9 +740,7 @@ impl Attr {
let first = input.try(|i| i.expect_ident_cloned()).ok(); let first = input.try(|i| i.expect_ident_cloned()).ok();
if let Ok(token) = input.try(|i| i.next_including_whitespace().map(|t| t.clone())) { if let Ok(token) = input.try(|i| i.next_including_whitespace().map(|t| t.clone())) {
match token { match token {
Token::Delim('|') => {} Token::Delim('|') => {
ref t => return Err(BasicParseError::UnexpectedToken(t.clone()).into()),
}
// must be followed by an ident // must be followed by an ident
let second_token = match *input.next_including_whitespace()? { let second_token = match *input.next_including_whitespace()? {
Token::Ident(ref second) => second, Token::Ident(ref second) => second,
@ -763,6 +761,12 @@ impl Attr {
attribute: second_token.as_ref().to_owned(), attribute: second_token.as_ref().to_owned(),
}) })
} }
// In the case of attr(foobar ) we don't want to error out
// because of the trailing whitespace
Token::WhiteSpace(_) => (),
ref t => return Err(BasicParseError::UnexpectedToken(t.clone()).into()),
}
}
if let Some(first) = first { if let Some(first) = first {
Ok(Attr { Ok(Attr {