File tree 2 files changed +40
-2
lines changed
2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,23 @@ module.exports = (options) => {
111
111
while ( rule . nodes . length > 0 ) {
112
112
destination . append ( rule . nodes [ 0 ] ) ;
113
113
}
114
+
115
+ // store the original rule parent before removal in case an atrule
116
+ // becomes empty as a result of the removal
117
+ const ruleParent = rule . parent ;
118
+
114
119
// remove duplicated rule
115
120
rule . remove ( ) ;
116
121
122
+ // on removal of the node, the parent atrule could have no
123
+ // declarations associated. This is an issue for @keyframes that
124
+ // interpret @keyframes <name> {} as overwriting existing keyframe
125
+ // transitions.
126
+ if ( ruleParent . type === 'atrule' && ruleParent . nodes . length === 0 ) {
127
+ const ruleParentIndex = ruleParent . parent . index ( ruleParent ) ;
128
+ ruleParent . parent . nodes [ ruleParentIndex ] . remove ( ) ;
129
+ }
130
+
117
131
if (
118
132
options . removeDuplicatedProperties ||
119
133
options . removeDuplicatedValues
Original file line number Diff line number Diff line change @@ -227,14 +227,39 @@ const cases = [
227
227
background: green;
228
228
}
229
229
}
230
- @media print { }
231
230
` ,
232
231
} ,
233
232
{
234
233
label : 'keyframe selectors with same percentage' ,
235
234
input : '@keyframes a {0% { color: blue; } 0% { background: green; }}' ,
236
235
expected : '@keyframes a {0% { color: blue; background: green; }}' ,
237
236
} ,
237
+ {
238
+ label : 'keyframe selectors with duplicate animation properties' ,
239
+ input : minify `
240
+ @keyframes ping {
241
+ 75%,
242
+ to {
243
+ transform: scale(2);
244
+ }
245
+ }
246
+ @keyframes ping {
247
+ 75%,
248
+ to {
249
+ opacity: 0;
250
+ }
251
+ }
252
+ ` ,
253
+ expected : minify `
254
+ @keyframes ping {
255
+ 75%,
256
+ to {
257
+ transform: scale(2);
258
+ opacity: 0;
259
+ }
260
+ }
261
+ ` ,
262
+ } ,
238
263
{
239
264
label : 'multiple print media queries with different case' ,
240
265
input : minify `
@@ -256,7 +281,6 @@ const cases = [
256
281
background: green;
257
282
}
258
283
}
259
- @MEDIA print { }
260
284
` ,
261
285
} ,
262
286
{
You can’t perform that action at this time.
0 commit comments