mirror of
https://github.com/swc-project/swc.git
synced 2024-12-29 00:23:10 +03:00
fix(css/minifier): Fix compressions of transform functions (#6617)
This commit is contained in:
parent
4d4406d5b3
commit
208fd559ba
@ -16,20 +16,20 @@ impl Compressor {
|
||||
match (function_value.get(0), function_value.get(2)) {
|
||||
(
|
||||
Some(first),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
) if *second_number == 0.0 => {
|
||||
) if *second_number == 0 => {
|
||||
*function_value = vec![first.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(second),
|
||||
) if *first_number == 0.0 => {
|
||||
) if *first_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("translateY"),
|
||||
@ -53,16 +53,16 @@ impl Compressor {
|
||||
function_value.get(4),
|
||||
) {
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(third),
|
||||
) if *first_number == 0.0 && *second_number == 0.0 => {
|
||||
) if *first_number == 0 && *second_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("translateZ"),
|
||||
@ -83,12 +83,12 @@ impl Compressor {
|
||||
match (function_value.get(0), function_value.get(2)) {
|
||||
(
|
||||
Some(
|
||||
first @ ComponentValue::Number(box Number {
|
||||
first @ ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
}),
|
||||
),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
@ -97,11 +97,11 @@ impl Compressor {
|
||||
}
|
||||
(
|
||||
Some(first),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
) if *second_number == 1.0 => {
|
||||
) if *second_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("scaleX"),
|
||||
@ -110,12 +110,12 @@ impl Compressor {
|
||||
*function_value = vec![first.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(second),
|
||||
) if *first_number == 1.0 => {
|
||||
) if *first_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("scaleY"),
|
||||
@ -140,15 +140,15 @@ impl Compressor {
|
||||
) {
|
||||
(
|
||||
Some(first),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
) if *second_number == 1.0 && *third_number == 1.0 => {
|
||||
) if *second_number == 1 && *third_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("scaleX"),
|
||||
@ -157,16 +157,16 @@ impl Compressor {
|
||||
*function_value = vec![first.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(second),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
) if *first_number == 1.0 && *third_number == 1.0 => {
|
||||
) if *first_number == 1 && *third_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("scaleY"),
|
||||
@ -175,16 +175,16 @@ impl Compressor {
|
||||
*function_value = vec![second.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(third),
|
||||
) if *first_number == 1.0 && *second_number == 1.0 => {
|
||||
) if *first_number == 1 && *second_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("scaleZ"),
|
||||
@ -230,11 +230,11 @@ impl Compressor {
|
||||
Some(first_comma),
|
||||
Some(second),
|
||||
Some(second_comma),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: fourth_number,
|
||||
..
|
||||
})),
|
||||
@ -242,51 +242,51 @@ impl Compressor {
|
||||
Some(fifth_comma),
|
||||
Some(sixth),
|
||||
Some(sixth_comma),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: seventh_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: eighth_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: ninth_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: tenth_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: eleventh_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: twelfth_number,
|
||||
..
|
||||
})),
|
||||
Some(thirteenth),
|
||||
Some(thirteenth_comma),
|
||||
Some(fourteenth),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: fifteenth_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: sixteenth_number,
|
||||
..
|
||||
})),
|
||||
) if *third_number == 0.0
|
||||
&& *fourth_number == 0.0
|
||||
&& *seventh_number == 0.0
|
||||
&& *eighth_number == 0.0
|
||||
&& *ninth_number == 0.0
|
||||
&& *tenth_number == 0.0
|
||||
&& *eleventh_number == 1.0
|
||||
&& *twelfth_number == 0.0
|
||||
&& *fifteenth_number == 0.0
|
||||
&& *sixteenth_number == 1.0 =>
|
||||
) if *third_number == 0
|
||||
&& *fourth_number == 0
|
||||
&& *seventh_number == 0
|
||||
&& *eighth_number == 0
|
||||
&& *ninth_number == 0
|
||||
&& *tenth_number == 0
|
||||
&& *eleventh_number == 1
|
||||
&& *twelfth_number == 0
|
||||
&& *fifteenth_number == 0
|
||||
&& *sixteenth_number == 1 =>
|
||||
{
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
@ -324,20 +324,20 @@ impl Compressor {
|
||||
function_value.get(6),
|
||||
) {
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
Some(fourth_value),
|
||||
) if *first_number == 1.0 && *second_number == 0.0 && *third_number == 0.0 => {
|
||||
) if *first_number == 1 && *second_number == 0 && *third_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("rotateX"),
|
||||
@ -346,20 +346,20 @@ impl Compressor {
|
||||
*function_value = vec![fourth_value.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
Some(fourth_value),
|
||||
) if *first_number == 0.0 && *second_number == 1.0 && *third_number == 0.0 => {
|
||||
) if *first_number == 0 && *second_number == 1 && *third_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("rotateY"),
|
||||
@ -368,20 +368,20 @@ impl Compressor {
|
||||
*function_value = vec![fourth_value.clone()];
|
||||
}
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: third_number,
|
||||
..
|
||||
})),
|
||||
Some(fourth_value),
|
||||
) if *first_number == 0.0 && *second_number == 0.0 && *third_number == 1.0 => {
|
||||
) if *first_number == 0 && *second_number == 0 && *third_number == 1 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("rotate"),
|
||||
@ -416,11 +416,11 @@ impl Compressor {
|
||||
match (function_value.get(0), function_value.get(2)) {
|
||||
(
|
||||
Some(first),
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: second_number,
|
||||
..
|
||||
})),
|
||||
) if *second_number == 0.0 => {
|
||||
) if *second_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("skewX"),
|
||||
@ -430,12 +430,12 @@ impl Compressor {
|
||||
}
|
||||
|
||||
(
|
||||
Some(ComponentValue::Number(box Number {
|
||||
Some(ComponentValue::Integer(box Integer {
|
||||
value: first_number,
|
||||
..
|
||||
})),
|
||||
Some(second),
|
||||
) if *first_number == 0.0 => {
|
||||
) if *first_number == 0 => {
|
||||
*name = Ident {
|
||||
span: name.span,
|
||||
value: js_word!("skewY"),
|
||||
|
@ -1 +1 @@
|
||||
.class1{transform:translate(5px)}.class2{transform:translate(5px,5px)}.class3{transform:translate(5px,0)}.class4{transform:translate(var(--foo),0)}.class5{transform:translate(var(--foo))}.class6{transform:translate(0,5px)}.class7{transform:translate(0,var(--foo))}.class8{transform:translate3d(0,0,0)}.class9{transform:translate3d(0,0,10px)}.class10{transform:translate3d(0,0,10px)}.class11{transform:translate3d(0,0,var(--foo))}.class12{transform:translate3d(0,var(--foo))}.class13{transform:translate3d(var(--foo))}.class14{transform:translate3d(var(--foo),0)}.class15{transform:translate3d(var(--foo),0,0)}.class16{transform:scale(0,0)}.class17{transform:scale(1.5)}.class18{transform:scale(1.5,1)}.class19{transform:scale(var(--foo),1)}.class20{transform:scale(1,1.5)}.class21{transform:scale(1,var(--foo))}.class22{transform:scale(1.5,3)}.class23{transform:scale(1.5)}.class24{transform:scale(1.5,1)}.class25{transform:scale(var(--foo))}.class26{transform:scale3d(1.5,1,1)}.class27{transform:scale3d(var(--foo),1,1)}.class28{transform:scale3d(1,1.5,1)}.class29{transform:scale3d(1,var(--foo),1)}.class30{transform:scale3d(1,1,1.5)}.class31{transform:scale3d(1,1,var(--foo))}.class32{transform:scale3d(1.5,1.5,3)}.class33{transform:scale3d(var(--foo))}.class34{transform:scale3d(1.5,var(--foo))}.class35{transform:scale3d(var(--foo),1.5)}.class36{transform:scale3d(var(--foo),var(--foo),var(--foo))}.class37{transform:matrix3d(20,20,0,0,40,40,0,0,0,0,1,0,80,80,0,1)}.class38{transform:matrix3d(20,20,0,0,40,40,0,0,0,0,1,0,80,80,0,1)}.class39{transform:matrix3d(var(--foo))}.class40{transform:matrix3d(var(--a1),var(--a2),var(--a3),var(--a4))}.class41{transform:matrix3d(var(--a1),var(--b1),var(--c1),var(--d1),var(--a2),var(--b2),var(--c2),var(--d2),var(--a3),var(--b3),var(--c3),var(--d3),var(--a4),var(--b4),var(--c4),var(--d4))}.class42{transform:matrix3d(var(--a),var(--b),0,0,var(--c),var(--d),0,0,0,0,1,0,var(--tx),var(--ty),0,1)}.class43{transform:rotate3d(1,0,0,20deg)}.class44{transform:rotate3d(1,0,0,var(--foo))}.class45{transform:rotate3d(0,1,0,20deg)}.class46{transform:rotate3d(0,1,0,var(--foo))}.class47{transform:rotate3d(0,0,1,20deg)}.class48{transform:rotate3d(0,0,1,var(--foo))}.class49{transform:rotate(20deg)}.class50{transform:rotate(var(--foo))}.class51{transform:skew(10deg,0)}.class52{transform:skew(var(--foo),0)}.class53{transform:skew(0,10deg)}.class54{transform:skew(0,var(--foo))}.class55{transform:skew(var(--foo))}.class56{transform:skew(12deg,20deg)}.class57{transform:skewy(10deg)}.class58{transform:rotate3d(1,0,0,0)}
|
||||
.class1{transform:translate(5px)}.class2{transform:translate(5px,5px)}.class3{transform:translate(5px)}.class4,.class5{transform:translate(var(--foo))}.class6{transform:translatey(5px)}.class7{transform:translatey(var(--foo))}.class8{transform:translatez(0)}.class9,.class10{transform:translatez(10px)}.class11{transform:translatez(var(--foo))}.class12{transform:translate3d(0,var(--foo))}.class13{transform:translate3d(var(--foo))}.class14{transform:translate3d(var(--foo),0)}.class15{transform:translate3d(var(--foo),0,0)}.class16{transform:scale(0)}.class17{transform:scale(1.5,1.5)}.class18{transform:scalex(1.5)}.class19{transform:scalex(var(--foo))}.class20{transform:scaley(1.5)}.class21{transform:scaley(var(--foo))}.class22{transform:scale(1.5,3)}.class23{transform:scale(1.5)}.class24{transform:scalex(1.5)}.class25{transform:scale(var(--foo))}.class26{transform:scalex(1.5)}.class27{transform:scalex(var(--foo))}.class28{transform:scaley(1.5)}.class29{transform:scaley(var(--foo))}.class30{transform:scalez(1.5)}.class31{transform:scalez(var(--foo))}.class32{transform:scale3d(1.5,1.5,3)}.class33{transform:scale3d(var(--foo))}.class34{transform:scale3d(1.5,var(--foo))}.class35{transform:scale3d(var(--foo),1.5)}.class36{transform:scale3d(var(--foo),var(--foo),var(--foo))}.class37,.class38{transform:matrix(20,20,40,40,80,80)}.class39{transform:matrix3d(var(--foo))}.class40{transform:matrix3d(var(--a1),var(--a2),var(--a3),var(--a4))}.class41{transform:matrix3d(var(--a1),var(--b1),var(--c1),var(--d1),var(--a2),var(--b2),var(--c2),var(--d2),var(--a3),var(--b3),var(--c3),var(--d3),var(--a4),var(--b4),var(--c4),var(--d4))}.class42{transform:matrix(var(--a),var(--b),var(--c),var(--d),var(--tx),var(--ty))}.class43{transform:rotatex(20deg)}.class44{transform:rotatex(var(--foo))}.class45{transform:rotatey(20deg)}.class46{transform:rotatey(var(--foo))}.class47{transform:rotate(20deg)}.class48{transform:rotate(var(--foo))}.class49{transform:rotate(20deg)}.class50{transform:rotate(var(--foo))}.class51{transform:skewx(10deg)}.class52{transform:skewx(var(--foo))}.class53{transform:skewy(10deg)}.class54{transform:skewy(var(--foo))}.class55{transform:skew(var(--foo))}.class56{transform:skew(12deg,20deg)}.class57{transform:skew(0,10deg)}.class58{transform:rotatex(0)}
|
||||
|
@ -1 +1 @@
|
||||
.deg{transform:rotate(0);transform:rotate(0);transform:rotate(9deg);transform:rotate(-9deg);transform:rotate(10deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(350deg);transform:rotate(-9deg);transform:rotate(0);transform:rotate(360.5deg);transform:rotate(-360.5deg);transform:rotate(1deg);transform:rotate(-1deg)}.grad{transform:rotate(0);transform:rotate(0);transform:rotate(9grad);transform:rotate(-9grad);transform:rotate(9deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(800.5grad);transform:rotate(-800.5grad);transform:rotate(821grad);transform:rotate(-821grad)}.rad{transform:rotate(0);transform:rotate(0);transform:rotate(1rad);transform:rotate(1.5rad);transform:rotate(-1.5rad)}.turn{transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(0);transform:rotate(180deg);transform:rotate(0)}.cross{transform:rotate(90deg);transform:rotate(90deg);transform:rotate(90deg);transform:rotate(1.57rad);transform:rotate(3.1416rad)}.class1{transform:rotate(0)}.class2,.class3{transform:skewx(0)}.class4{transform:skewy(0)}.class5{transform:rotate3d(10,10,10,0)}.class6{transform:rotatex(0)}.class7{transform:rotatey(0)}.class8{transform:rotate(0)}.class9,.class10{transform:rotate(0)}.class11{transform:rotate(0)}@keyframes spinner-border{to{transform:rotate(360deg)}}
|
||||
.deg{transform:rotate(0);transform:rotate(0);transform:rotate(9deg);transform:rotate(-9deg);transform:rotate(10deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(350deg);transform:rotate(-9deg);transform:rotate(0);transform:rotate(360.5deg);transform:rotate(-360.5deg);transform:rotate(1deg);transform:rotate(-1deg)}.grad{transform:rotate(0);transform:rotate(0);transform:rotate(9grad);transform:rotate(-9grad);transform:rotate(9deg);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(0);transform:rotate(800.5grad);transform:rotate(-800.5grad);transform:rotate(821grad);transform:rotate(-821grad)}.rad{transform:rotate(0);transform:rotate(0);transform:rotate(1rad);transform:rotate(1.5rad);transform:rotate(-1.5rad)}.turn{transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(180deg);transform:rotate(0);transform:rotate(0);transform:rotate(180deg);transform:rotate(0);transform:rotate(180deg);transform:rotate(0)}.cross{transform:rotate(90deg);transform:rotate(90deg);transform:rotate(90deg);transform:rotate(1.57rad);transform:rotate(3.1416rad)}.class1{transform:rotate(0)}.class2{transform:skew(0,0)}.class3{transform:skewx(0)}.class4{transform:skewy(0)}.class5{transform:rotate3d(10,10,10,0)}.class6{transform:rotatex(0)}.class7{transform:rotatey(0)}.class8{transform:rotate(0)}.class9,.class10{transform:rotate(0)}.class11{transform:rotate(0)}@keyframes spinner-border{to{transform:rotate(360deg)}}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user