Skip to content

Commit

Permalink
Fix parsing list-style shorthand
Browse files Browse the repository at this point in the history
list-style-type should be parsed last since it allows custom keywords. Fixes #867
  • Loading branch information
devongovett committed Dec 21, 2024
1 parent d45cf88 commit 97891d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
35 changes: 31 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16380,7 +16380,7 @@ mod tests {
);
minify_test(
".foo { list-style: \"★\" url(ellipse.png) outside; }",
".foo{list-style:\"★\" url(ellipse.png)}",
".foo{list-style:url(ellipse.png) \"★\"}",
);

test(
Expand Down Expand Up @@ -16421,7 +16421,7 @@ mod tests {
"#,
indoc! {r#"
.foo {
list-style: \"★\" url("ellipse.png");
list-style: url("ellipse.png") \"★\";
list-style-image: var(--img);
}
"#},
Expand All @@ -16447,8 +16447,8 @@ mod tests {
".foo { list-style: \"★\" linear-gradient(lch(56.208% 136.76 46.312), lch(51% 135.366 301.364)) }",
indoc! { r#"
.foo {
list-style: "★" linear-gradient(#ff0f0e, #7773ff);
list-style: "★" linear-gradient(lch(56.208% 136.76 46.312), lch(51% 135.366 301.364));
list-style: linear-gradient(#ff0f0e, #7773ff) "★";
list-style: linear-gradient(lch(56.208% 136.76 46.312), lch(51% 135.366 301.364)) "★";
}
"#},
Browsers {
Expand All @@ -16475,6 +16475,33 @@ mod tests {
..Browsers::default()
},
);

test(
r#"
.foo {
list-style: inside;
list-style-type: disc;
}
"#,
indoc! {r#"
.foo {
list-style: inside;
}
"#},
);
test(
r#"
.foo {
list-style: inside;
list-style-type: decimal;
}
"#,
indoc! {r#"
.foo {
list-style: inside decimal;
}
"#},
);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions src/properties/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,13 @@ enum_property! {
shorthand_property! {
/// A value for the [list-style](https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#list-style-property) shorthand property.
pub struct ListStyle<'i> {
/// The list style type.
#[cfg_attr(feature = "serde", serde(borrow))]
list_style_type: ListStyleType(ListStyleType<'i>),
/// The list marker image.
image: ListStyleImage(Image<'i>),
/// The position of the list marker.
position: ListStylePosition(ListStylePosition),
/// The list marker image.
#[cfg_attr(feature = "serde", serde(borrow))]
image: ListStyleImage(Image<'i>),
/// The list style type.
list_style_type: ListStyleType(ListStyleType<'i>),
}
}

Expand Down

0 comments on commit 97891d8

Please sign in to comment.