Use CustomIdent in Symbol::Ident

The former code was not following the spec.
This commit is contained in:
Anthony Ramine 2018-03-02 21:02:03 +01:00
parent a71b5d5e16
commit ad7adee882
5 changed files with 51 additions and 6 deletions

View file

@ -8,7 +8,7 @@
use Atom;
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser};
use cssparser::{Parser, Token, serialize_identifier, CowRcStr};
use cssparser::{Parser, Token, CowRcStr};
use error_reporting::{ContextualParseError, ParseErrorReporter};
#[cfg(feature = "gecko")] use gecko::rules::CounterStyleDescriptors;
#[cfg(feature = "gecko")] use gecko_bindings::structs::{ nsCSSCounterDesc, nsCSSValue };
@ -395,8 +395,8 @@ impl ToCss for System {
pub enum Symbol {
/// <string>
String(String),
/// <ident>
Ident(String),
/// <custom-ident>
Ident(CustomIdent),
// Not implemented:
// /// <image>
// Image(Image),
@ -407,7 +407,11 @@ impl Parse for Symbol {
let location = input.current_source_location();
match *input.next()? {
Token::QuotedString(ref s) => Ok(Symbol::String(s.as_ref().to_owned())),
Token::Ident(ref s) => Ok(Symbol::Ident(s.as_ref().to_owned())),
Token::Ident(ref s) => {
Ok(Symbol::Ident(
CustomIdent::from_ident(location, s, &[])?,
))
}
ref t => Err(location.new_unexpected_token_error(t.clone())),
}
}
@ -420,7 +424,7 @@ impl ToCss for Symbol {
{
match *self {
Symbol::String(ref s) => s.to_css(dest),
Symbol::Ident(ref s) => serialize_identifier(s, dest),
Symbol::Ident(ref s) => s.to_css(dest),
}
}
}