mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Fixed AttrValue::from_tokenlist indexes
The following issues were found: - Single concatenated spaces were indexed as a single token; - Last token, if not followed by an HTML space character, was ignored;
This commit is contained in:
parent
5f449019aa
commit
592454defd
1 changed files with 6 additions and 1 deletions
|
@ -37,10 +37,15 @@ impl AttrValue {
|
|||
pub fn from_tokenlist(list: DOMString) -> AttrValue {
|
||||
let mut indexes = vec![];
|
||||
let mut last_index: uint = 0;
|
||||
let length = list.len() - 1;
|
||||
for (index, ch) in list.as_slice().char_indices() {
|
||||
if HTML_SPACE_CHARACTERS.iter().any(|&space| space == ch) {
|
||||
indexes.push((last_index, index));
|
||||
if last_index != index {
|
||||
indexes.push((last_index, index));
|
||||
}
|
||||
last_index = index + 1;
|
||||
} else if index == length {
|
||||
indexes.push((last_index, index + 1));
|
||||
}
|
||||
}
|
||||
return TokenListAttrValue(list, indexes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue