use cssparser::Parser;
use selectors::matching;
use selectors::parser::{self, ParserContext, SelectorImpl};
use element_ref::ElementRef;
#[derive(Debug, Clone, PartialEq)]
pub struct Selector {
pub selectors: Vec<parser::Selector<Simple>>,
}
impl Selector {
pub fn parse(selectors: &str) -> Result<Self, ()> {
let mut parser = Parser::new(selectors);
let context = ParserContext::new();
let selectors = try!(parser::parse_selector_list(&context, &mut parser));
Ok(Selector { selectors: selectors })
}
pub fn matches(&self, element: &ElementRef) -> bool {
matching::matches(&self.selectors, element, None)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Simple;
impl SelectorImpl for Simple {
type NonTSPseudoClass = ();
type PseudoElement = ();
}