Skip to content

Commit 35cd802

Browse files
authored
Parse :state pseudo class (#228)
Signed-off-by: Simon Wülker <[email protected]>
1 parent 8d42ac8 commit 35cd802

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

style/servo/selector_parser.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,12 @@ impl ToCss for NonTSPseudoClass {
410410
Self::UserValid => ":user-valid",
411411
Self::Valid => ":valid",
412412
Self::Visited => ":visited",
413-
Self::Lang(_) | Self::CustomState(_) => unreachable!(),
413+
NonTSPseudoClass::CustomState(ref state) => {
414+
dest.write_str(":state(")?;
415+
state.0.to_css(dest)?;
416+
return dest.write_char(')');
417+
},
418+
Self::Lang(_) => unreachable!(),
414419
})
415420
}
416421
}
@@ -597,10 +602,13 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
597602
parser: &mut CssParser<'i, 't>,
598603
after_part: bool,
599604
) -> Result<NonTSPseudoClass, ParseError<'i>> {
600-
use self::NonTSPseudoClass::*;
601605
let pseudo_class = match_ignore_ascii_case! { &name,
602606
"lang" if !after_part => {
603-
Lang(parser.expect_ident_or_string()?.as_ref().into())
607+
NonTSPseudoClass::Lang(parser.expect_ident_or_string()?.as_ref().into())
608+
},
609+
"state" => {
610+
let result = AtomIdent::from(parser.expect_ident()?.as_ref());
611+
NonTSPseudoClass::CustomState(CustomState(result))
604612
},
605613
_ => return Err(parser.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name.clone()))),
606614
};

0 commit comments

Comments
 (0)