Skip to content

Commit d4eec35

Browse files
committed
Ensure consistent order of custom properties with all property
Fixes #855
1 parent 4159bc5 commit d4eec35

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const-str = "0.3.1"
7272
pathdiff = "0.2.1"
7373
ahash = "0.8.7"
7474
paste = "1.0.12"
75+
indexmap = "2.2.6"
7576
# CLI deps
7677
atty = { version = "0.2", optional = true }
7778
clap = { version = "3.0.6", features = ["derive"], optional = true }

src/declaration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! CSS declarations.
22
33
use std::borrow::Cow;
4-
use std::collections::HashMap;
54
use std::ops::Range;
65

76
use crate::context::{DeclarationContext, PropertyHandlerContext};
@@ -41,6 +40,7 @@ use crate::values::string::CowArcStr;
4140
#[cfg(feature = "visitor")]
4241
use crate::visitor::Visit;
4342
use cssparser::*;
43+
use indexmap::IndexMap;
4444

4545
/// A CSS declaration block.
4646
///
@@ -518,7 +518,7 @@ pub(crate) struct DeclarationHandler<'i> {
518518
prefix: PrefixHandler,
519519
direction: Option<Direction>,
520520
unicode_bidi: Option<UnicodeBidi>,
521-
custom_properties: HashMap<DashedIdent<'i>, usize>,
521+
custom_properties: IndexMap<DashedIdent<'i>, usize>,
522522
decls: DeclarationList<'i>,
523523
}
524524

@@ -609,7 +609,7 @@ impl<'i> DeclarationHandler<'i> {
609609
direction: self.direction.clone(),
610610
..Default::default()
611611
};
612-
for (key, index) in self.custom_properties.drain() {
612+
for (key, index) in self.custom_properties.drain(..) {
613613
handler.custom_properties.insert(key, handler.decls.len());
614614
handler.decls.push(self.decls[index].clone());
615615
}

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28355,5 +28355,9 @@ mod tests {
2835528355
".foo { all: unset; background: var(--foo); }",
2835628356
".foo{all:unset;background:var(--foo)}",
2835728357
);
28358+
minify_test(
28359+
".foo {--bar:currentcolor; --foo:1.1em; all:unset}",
28360+
".foo{--bar:currentcolor;--foo:1.1em;all:unset}",
28361+
);
2835828362
}
2835928363
}

0 commit comments

Comments
 (0)