Fixed serialize_list to no longer append an additional space at the end of the string

This commit is contained in:
Martin Tomasi 2015-08-29 09:21:02 +02:00
parent 5478c7c24b
commit ccddc3c13e
5 changed files with 49 additions and 5 deletions

View file

@ -20,6 +20,7 @@ use util::str::DOMString;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Ref;
use std::slice::SliceConcatExt;
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
#[dom_struct]
@ -50,9 +51,8 @@ macro_rules! css_properties(
);
fn serialize_list(list: &[Ref<PropertyDeclaration>]) -> DOMString {
list.iter().fold(String::new(), |accum, ref declaration| {
accum + &declaration.value() + " "
})
let strings: Vec<_> = list.iter().map(|d| d.value()).collect();
strings.join(" ")
}
impl CSSStyleDeclaration {

View file

@ -30,6 +30,7 @@
#![feature(str_utf16)]
#![feature(unicode)]
#![feature(vec_push_all)]
#![feature(slice_concat_ext)]
#![deny(unsafe_code)]
#![allow(non_snake_case)]

View file

@ -29055,6 +29055,27 @@
},
"local_changes": {
"deleted": [],
"items": {},
"deleted": [
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-002.html",
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-006.html",
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-004.html",
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-003.html",
"2dcontext/transformations/canvas_transformations_reset_001.htm",
"shadow-dom/shadow-trees/hosting-multiple-shadow-trees-005.html"
],
"items": {
"testharness": {
"dom/nodes/CharacterData-surrogates.html": [
{
"path": "dom/nodes/CharacterData-surrogates.html",
"url": "/dom/nodes/CharacterData-surrogates.html"
}
]
}
},
"items": {},
"reftest_nodes": {}
},
@ -34463,4 +34484,4 @@
"rev": "cf8340b5fae7b820788ffc31f8cc6b6b04978002",
"url_base": "/",
"version": 2
}
}

View file

@ -737,6 +737,12 @@
"url": "/_mozilla/mozilla/storage.html"
}
],
"mozilla/style_no_trailing_space.html": [
{
"path": "mozilla/style_no_trailing_space.html",
"url": "/_mozilla/mozilla/style_no_trailing_space.html"
}
],
"mozilla/textcontent.html": [
{
"path": "mozilla/textcontent.html",
@ -1064,4 +1070,4 @@
"rev": null,
"url_base": "/_mozilla/",
"version": 2
}
}

View file

@ -0,0 +1,16 @@
<html>
<head>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="foo" style="border-width: 1px"></div>
<script>
test(function() {
var border_width = document.getElementById("foo").style["borderWidth"];
assert_equals(border_width, "1px 1px 1px 1px");
});
</script>
</body>
</html>