mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Split class names using split_html_space_chars helper function
This commit is contained in:
parent
594df4d696
commit
943743195f
2 changed files with 4 additions and 5 deletions
|
@ -29,7 +29,7 @@ use layout_interface::{MatchSelectorsDocumentDamage};
|
|||
use style;
|
||||
use servo_util::namespace;
|
||||
use servo_util::namespace::{Namespace, Null};
|
||||
use servo_util::str::{DOMString, null_str_as_empty_ref};
|
||||
use servo_util::str::{DOMString, null_str_as_empty_ref, split_html_space_chars};
|
||||
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::cast;
|
||||
|
@ -376,9 +376,8 @@ impl AttributeHandlers for JS<Element> {
|
|||
}
|
||||
|
||||
fn has_class(&self, name: &str) -> bool {
|
||||
// FIXME: https://github.com/mozilla/servo/issues/1840
|
||||
let class_names = self.get_string_attribute("class");
|
||||
let mut classes = class_names.split(' ');
|
||||
let mut classes = split_html_space_chars(class_names);
|
||||
classes.any(|class| name == class)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use dom::element::{Element, AttributeHandlers};
|
|||
use dom::node::{Node, NodeHelpers};
|
||||
use dom::window::Window;
|
||||
use servo_util::namespace::Namespace;
|
||||
use servo_util::str::DOMString;
|
||||
use servo_util::str::{DOMString, split_html_space_chars};
|
||||
|
||||
use serialize::{Encoder, Encodable};
|
||||
|
||||
|
@ -100,7 +100,7 @@ impl HTMLCollection {
|
|||
}
|
||||
}
|
||||
let filter = ClassNameFilter {
|
||||
classes: classes.split(' ').map(|class| class.into_owned()).to_owned_vec()
|
||||
classes: split_html_space_chars(classes).map(|class| class.into_owned()).to_owned_vec()
|
||||
};
|
||||
HTMLCollection::create(window, root, ~filter)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue