From bdd3ab1fe067b27a0673ebd14be4de3833492a53 Mon Sep 17 00:00:00 2001 From: Eddie Quan Date: Tue, 14 Feb 2017 12:05:41 -0500 Subject: [PATCH] fixes quote transform: none serialization --- .../style/properties/longhand/list.mako.rs | 4 ++++ tests/unit/style/properties/serialization.rs | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 91e003d2575..a5a1c30861a 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -54,6 +54,10 @@ ${helpers.predefined_type("list-style-image", "UrlOrNone", "Either::Second(None_ impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + if self.0.is_empty() { + return dest.write_str("none") + } + let mut first = true; for pair in &self.0 { if !first { diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index da2574a575d..44fec3b5b24 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1114,4 +1114,28 @@ mod shorthand_serialization { assert_eq!(s, "none"); } } + + mod quotes { + pub use super::*; + + #[test] + fn should_serialize_none_correctly() { + use cssparser::Parser; + use media_queries::CSSErrorReporterTest; + use style::parser::ParserContext; + use style::properties::longhands::quotes; + use style::stylesheets::Origin; + + let mut s = String::new(); + let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); + let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); + + let parsed = quotes::parse(&context, &mut Parser::new("none")).unwrap(); + let try_serialize = parsed.to_css(&mut s); + + assert_eq!(try_serialize.is_ok(), true); + assert_eq!(s, "none"); + } + + } }