Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: parcel-bundler/lightningcss
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.29.0
Choose a base ref
...
head repository: parcel-bundler/lightningcss
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b10f9baf8878411bf2b09dfe8d64ba09ef7a4eac
Choose a head ref
  • 4 commits
  • 8 files changed
  • 1 contributor

Commits on Jan 9, 2025

  1. Verified

    This commit was signed with the committer’s verified signature.
    scothis Scott Andrews
    Copy the full SHA
    e3b1e88 View commit details
  2. v1.29.1

    devongovett committed Jan 9, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    scothis Scott Andrews
    Copy the full SHA
    4d34f98 View commit details
  3. Update artifact actions

    devongovett committed Jan 9, 2025

    Verified

    This commit was signed with the committer’s verified signature.
    scothis Scott Andrews
    Copy the full SHA
    b3a168e View commit details
  4. fix ci?

    devongovett committed Jan 9, 2025
    Copy the full SHA
    b10f9ba View commit details
Showing with 133 additions and 16 deletions.
  1. +8 −6 .github/workflows/release.yml
  2. +3 −3 Cargo.lock
  3. +1 −1 Cargo.toml
  4. +2 −2 napi/Cargo.toml
  5. +1 −1 node/Cargo.toml
  6. +1 −1 package.json
  7. +11 −0 src/lib.rs
  8. +106 −2 src/properties/list.rs
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ jobs:
if: ${{ matrix.strip }}
run: ${{ matrix.strip }} *.node ${{ matrix.binary }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: |
@@ -90,7 +90,7 @@ jobs:
- name: Strip debug symbols # https://github.com/rust-lang/rust/issues/46034
run: strip -x *.node lightningcss
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-aarch64-apple-darwin
path: |
@@ -153,7 +153,7 @@ jobs:
if: ${{ matrix.strip }}
run: ${{ matrix.strip }} *.node lightningcss
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.target }}
path: |
@@ -201,7 +201,7 @@ jobs:
rm -rf .yarn/cache
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bindings-x86_64-unknown-freebsd
path: |
@@ -232,7 +232,7 @@ jobs:
export PATH="$PATH:./binaryen-version_111/bin"
yarn wasm:build-release
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wasm
path: wasm/lightningcss_node.wasm
@@ -250,9 +250,11 @@ jobs:
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1.8.32
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Show artifacts
run: ls -R artifacts
- name: Build npm packages
run: |
node scripts/build-npm.js
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ members = [
[package]
authors = ["Devon Govett <devongovett@gmail.com>"]
name = "lightningcss"
version = "1.0.0-alpha.62"
version = "1.0.0-alpha.63"
description = "A CSS parser, transformer, and minifier"
license = "MPL-2.0"
edition = "2021"
4 changes: 2 additions & 2 deletions napi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Devon Govett <devongovett@gmail.com>"]
name = "lightningcss-napi"
version = "0.4.2"
version = "0.4.3"
description = "Node-API bindings for Lightning CSS"
license = "MPL-2.0"
repository = "https://github.com/parcel-bundler/lightningcss"
@@ -16,7 +16,7 @@ bundler = ["dep:crossbeam-channel", "dep:rayon"]
serde = { version = "1.0.201", features = ["derive"] }
serde_bytes = "0.11.5"
cssparser = "0.33.0"
lightningcss = { version = "1.0.0-alpha.62", path = "../", features = [
lightningcss = { version = "1.0.0-alpha.63", path = "../", features = [
"nodejs",
"serde",
] }
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
lightningcss-napi = { version = "0.4.2", path = "../napi", features = [
lightningcss-napi = { version = "0.4.3", path = "../napi", features = [
"bundler",
"visitor",
] }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightningcss",
"version": "1.29.0",
"version": "1.29.1",
"license": "MPL-2.0",
"description": "A CSS parser, transformer, and minifier written in Rust",
"main": "node/index.js",
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -16652,6 +16652,17 @@ mod tests {
".foo { list-style: \"★\" url(ellipse.png) outside; }",
".foo{list-style:url(ellipse.png) \"★\"}",
);
minify_test(".foo { list-style: none; }", ".foo{list-style:none}");
minify_test(".foo { list-style: none none outside; }", ".foo{list-style:none}");
minify_test(".foo { list-style: none none inside; }", ".foo{list-style:inside none}");
minify_test(".foo { list-style: none inside; }", ".foo{list-style:inside none}");
minify_test(".foo { list-style: none disc; }", ".foo{list-style:outside}");
minify_test(".foo { list-style: none inside disc; }", ".foo{list-style:inside}");
minify_test(".foo { list-style: none \"★\"; }", ".foo{list-style:\"★\"}");
minify_test(
".foo { list-style: none url(foo.png); }",
".foo{list-style:url(foo.png) none}",
);

test(
r#"
108 changes: 106 additions & 2 deletions src/properties/list.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ use super::{Property, PropertyId};
use crate::context::PropertyHandlerContext;
use crate::declaration::{DeclarationBlock, DeclarationList};
use crate::error::{ParserError, PrinterError};
use crate::macros::{define_shorthand, enum_property, shorthand_handler, shorthand_property};
use crate::macros::{define_shorthand, enum_property, shorthand_handler};
use crate::printer::Printer;
use crate::targets::{Browsers, Targets};
use crate::traits::{FallbackValues, IsCompatible, Parse, PropertyHandler, Shorthand, ToCss};
@@ -329,7 +329,7 @@ enum_property! {
}
}

shorthand_property! {
define_shorthand! {
/// 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 position of the list marker.
@@ -342,6 +342,110 @@ shorthand_property! {
}
}

impl<'i> Parse<'i> for ListStyle<'i> {
fn parse<'t>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i, ParserError<'i>>> {
let mut position = None;
let mut image = None;
let mut list_style_type = None;
let mut nones = 0;

loop {
// `none` is ambiguous - both list-style-image and list-style-type support it.
if input.try_parse(|input| input.expect_ident_matching("none")).is_ok() {
nones += 1;
if nones > 2 {
return Err(input.new_custom_error(ParserError::InvalidValue));
}
continue;
}

if image.is_none() {
if let Ok(val) = input.try_parse(Image::parse) {
image = Some(val);
continue;
}
}

if position.is_none() {
if let Ok(val) = input.try_parse(ListStylePosition::parse) {
position = Some(val);
continue;
}
}

if list_style_type.is_none() {
if let Ok(val) = input.try_parse(ListStyleType::parse) {
list_style_type = Some(val);
continue;
}
}

break;
}

// Assign the `none` to the opposite property from the one we have a value for,
// or both in case neither list-style-image or list-style-type have a value.
match (nones, image, list_style_type) {
(2, None, None) | (1, None, None) => Ok(ListStyle {
position: position.unwrap_or_default(),
image: Image::None,
list_style_type: ListStyleType::None,
}),
(1, Some(image), None) => Ok(ListStyle {
position: position.unwrap_or_default(),
image,
list_style_type: ListStyleType::None,
}),
(1, None, Some(list_style_type)) => Ok(ListStyle {
position: position.unwrap_or_default(),
image: Image::None,
list_style_type,
}),
(0, image, list_style_type) => Ok(ListStyle {
position: position.unwrap_or_default(),
image: image.unwrap_or_default(),
list_style_type: list_style_type.unwrap_or_default(),
}),
_ => Err(input.new_custom_error(ParserError::InvalidValue)),
}
}
}

impl<'i> ToCss for ListStyle<'i> {
fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError>
where
W: std::fmt::Write,
{
let mut needs_space = false;
if self.position != ListStylePosition::default() {
self.position.to_css(dest)?;
needs_space = true;
}

if self.image != Image::default() {
if needs_space {
dest.write_char(' ')?;
}
self.image.to_css(dest)?;
needs_space = true;
}

if self.list_style_type != ListStyleType::default() {
if needs_space {
dest.write_char(' ')?;
}
self.list_style_type.to_css(dest)?;
needs_space = true;
}

if !needs_space {
self.position.to_css(dest)?;
}

Ok(())
}
}

impl<'i> FallbackValues for ListStyle<'i> {
fn get_fallbacks(&mut self, targets: Targets) -> Vec<Self> {
self