From ec87545774c819cde014eed0cac83fe007fa6a4d Mon Sep 17 00:00:00 2001 From: "Panashe M. Fundira" Date: Sat, 11 Mar 2017 20:50:41 -0500 Subject: [PATCH] PropertyDeclaration with CSSWideKeyword is parsed Addresses #15401 The desired result is for `CSSWideKeyword`s to return false (they are parsed) and other Custom declaration values to return true (they are unparsed). --- .../style/properties/properties.mako.rs | 4 +++- tests/unit/style/properties/serialization.rs | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 5dca7bee0cc..4b360fea1d2 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1174,7 +1174,9 @@ impl PropertyDeclaration { pub fn value_is_unparsed(&self) -> bool { match *self { PropertyDeclaration::WithVariables(..) => true, - PropertyDeclaration::Custom(..) => true, + PropertyDeclaration::Custom(_, ref value) => { + !matches!(value.borrow(), DeclaredValue::CSSWideKeyword(..)) + } _ => false, } } diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 1eb5b75feb8..a9eabc1be8c 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1124,4 +1124,25 @@ mod shorthand_serialization { assert_eq!(serialization, block_text); } } + + mod keywords { + pub use super::*; + #[test] + fn css_wide_keywords_should_be_parsed() { + let block_text = "--a:inherit;"; + let block = parse_declaration_block(block_text); + + let serialization = block.to_css_string(); + assert_eq!(serialization, "--a: inherit;"); + } + + #[test] + fn non_keyword_custom_property_should_be_unparsed() { + let block_text = "--main-color: #06c;"; + let block = parse_declaration_block(block_text); + + let serialization = block.to_css_string(); + assert_eq!(serialization, block_text); + } + } }