mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
auto merge of #2032 : brunoabinader/servo/html-whitespace, r=Ms2ger
Specs: http://dom.spec.whatwg.org/#concept-ordered-set-parser http://encoding.spec.whatwg.org/#ascii-whitespace This PR implements the HTMLSpaceCharSplits iterator, used to split a string in a subset of strings separated by valid HTML space characters. Its first usage is upon splitting ```class``` attribute values. Closes #1840.
This commit is contained in:
commit
2a5f82a764
5 changed files with 40 additions and 6 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