Skip to content

Serialize currentcolor as canonicalized form #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "cssparser"
version = "0.16.0"
version = "0.17.0"
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]

description = "Rust implementation of CSS Syntax Level 3"
Expand Down
4 changes: 2 additions & 2 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl ToCss for RGBA {
/// A <color> value.
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Color {
/// The 'currentColor' keyword
/// The 'currentcolor' keyword
CurrentColor,
/// Everything else gets converted to RGBA during parsing
RGBA(RGBA),
Expand All @@ -130,7 +130,7 @@ known_heap_size!(0, Color);
impl ToCss for Color {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
Color::CurrentColor => dest.write_str("currentColor"),
Color::CurrentColor => dest.write_str("currentcolor"),
Color::RGBA(ref rgba) => rgba.to_css(dest),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/css-parsing-tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ associated with the expected result.
the output as one of:

* null if the input is not a valid color in CSS syntax
* The string "currentColor" for the currentColor keyword
* The string "currentcolor" for the currentcolor keyword
* An array of length 4 for every other values:
four (floating point) numbers for the Red, Green, Blue and Alpha channel.
Each value is between 0 and 1.
Expand Down
5 changes: 3 additions & 2 deletions src/css-parsing-tests/color3.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"transparent", [0, 0, 0, 0],
" transparent\n", [0, 0, 0, 0],
"TransParent", [0, 0, 0, 0],
"currentColor", "currentColor",
"CURRENTcolor", "currentColor",
"currentcolor", "currentcolor",
"currentColor", "currentcolor",
"CURRENTcolor", "currentcolor",
"current-Color", null,

"black", [0, 0, 0, 255],
Expand Down
4 changes: 2 additions & 2 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ fn serializer(preserve_comments: bool) {
#[test]
fn serialize_current_color() {
let c = Color::CurrentColor;
assert!(c.to_css_string() == "currentColor");
assert!(c.to_css_string() == "currentcolor");
}

#[test]
Expand Down Expand Up @@ -622,7 +622,7 @@ impl ToJson for Color {
Color::RGBA(ref rgba) => {
[rgba.red, rgba.green, rgba.blue, rgba.alpha].to_json()
},
Color::CurrentColor => "currentColor".to_json(),
Color::CurrentColor => "currentcolor".to_json(),
}
}
}
Expand Down