Make use of the list of Atoms in ClassSelector

Make use of the list of Atoms in the class attribute selector
(ClassSelector) in selector_matching.

Fixes #3111
This commit is contained in:
Gilles Leblanc 2014-09-11 23:19:26 -04:00
parent a18633b163
commit 81a0d065f1
8 changed files with 71 additions and 5 deletions

View file

@ -30,5 +30,6 @@ pub trait TElement {
fn get_id(&self) -> Option<Atom>;
fn get_disabled_state(&self) -> bool;
fn get_enabled_state(&self) -> bool;
fn has_class(&self, name: &str) -> bool;
}

View file

@ -626,11 +626,7 @@ fn matches_simple_selector<E:TElement,
// TODO: cache and intern class names on elements.
ClassSelector(ref class) => {
let element = element.as_element();
element.get_attr(&namespace::Null, "class")
.map_or(false, |attr| {
// TODO: case-sensitivity depends on the document type and quirks mode
attr.split(SELECTOR_WHITESPACE).any(|c| c == class.as_slice())
})
element.has_class(class.as_slice())
}
AttrExists(ref attr) => {