Skip to content

Commit a8d909a

Browse files
Devon GovettDevon Govett
authored andcommitted
Fix deduplicating multiple instances of a rule
Fixes parcel-bundler#525
1 parent cc1aa63 commit a8d909a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8921,6 +8921,31 @@ mod tests {
89218921
}
89228922
"#},
89238923
);
8924+
test(
8925+
r#"
8926+
.a {
8927+
color: red;
8928+
}
8929+
.b {
8930+
color: green;
8931+
}
8932+
.a {
8933+
color: red;
8934+
}
8935+
.b {
8936+
color: green;
8937+
}
8938+
"#,
8939+
indoc! {r#"
8940+
.a {
8941+
color: red;
8942+
}
8943+
8944+
.b {
8945+
color: green;
8946+
}
8947+
"#},
8948+
);
89248949

89258950
prefix_test(
89268951
r#"

src/rules/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ impl<'i, T: Clone> CssRuleList<'i, T> {
705705
let key = StyleRuleKey::new(unsafe { &*(&rules as *const _) }, idx);
706706
if idx > 0 {
707707
if let Some(i) = style_rules.remove(&key) {
708-
if let CssRule::Style(other) = &rules[0] {
708+
if let CssRule::Style(other) = &rules[i] {
709709
// Don't remove the rule if this is a CSS module and the other rule came from a different file.
710710
if !context.css_modules || source_index == other.loc.source_index {
711711
// Only mark the rule as ignored so we don't need to change all of the indices.

0 commit comments

Comments
 (0)