mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Use AttrValue::tokens() in Element::has_class()
This commit is contained in:
parent
e9f9afc324
commit
d17450106c
1 changed files with 6 additions and 4 deletions
|
@ -35,7 +35,7 @@ use style;
|
||||||
use servo_util::atom::Atom;
|
use servo_util::atom::Atom;
|
||||||
use servo_util::namespace;
|
use servo_util::namespace;
|
||||||
use servo_util::namespace::{Namespace, Null};
|
use servo_util::namespace::{Namespace, Null};
|
||||||
use servo_util::str::{DOMString, null_str_as_empty_ref, split_html_space_chars};
|
use servo_util::str::{DOMString, null_str_as_empty_ref};
|
||||||
|
|
||||||
use std::ascii::StrAsciiExt;
|
use std::ascii::StrAsciiExt;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
@ -377,9 +377,11 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_class(&self, name: &str) -> bool {
|
fn has_class(&self, name: &str) -> bool {
|
||||||
let class_names = self.get_string_attribute("class");
|
self.get_attribute(Null, "class").root().map(|attr| {
|
||||||
let mut classes = split_html_space_chars(class_names.as_slice());
|
attr.deref().value().tokens().map(|mut tokens| {
|
||||||
classes.any(|class| name == class)
|
tokens.any(|atom| atom.as_slice() == name)
|
||||||
|
}).unwrap_or(false)
|
||||||
|
}).unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_atomic_attribute(&self, name: &str, value: DOMString) {
|
fn set_atomic_attribute(&self, name: &str, value: DOMString) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue