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

View file

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

View file

@ -29055,6 +29055,27 @@
}, },
"local_changes": { "local_changes": {
"deleted": [], "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": {}, "items": {},
"reftest_nodes": {} "reftest_nodes": {}
}, },

View file

@ -737,6 +737,12 @@
"url": "/_mozilla/mozilla/storage.html" "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": [ "mozilla/textcontent.html": [
{ {
"path": "mozilla/textcontent.html", "path": "mozilla/textcontent.html",

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>