Skip to content

Commit 3d3863d

Browse files
authoredDec 16, 2022
feat(css/parser): Normalize dimension (#6654)
1 parent 779383a commit 3d3863d

File tree

24 files changed

+668
-143
lines changed

24 files changed

+668
-143
lines changed
 

‎crates/swc_css_ast/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod value;
1414
///
1515
/// The type of value and patterns should be identical.
1616
///
17-
/// # Exmaples
17+
/// # Examples
1818
///
1919
/// ```
2020
/// use swc_atoms::JsWord;

‎crates/swc_css_minifier/src/compressor/angle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Compressor {
3737
return;
3838
}
3939

40-
let from = match get_angle_type(&angle.unit.value.to_ascii_lowercase()) {
40+
let from = match get_angle_type(&angle.unit.value) {
4141
Some(angel_type) => angel_type,
4242
None => return,
4343
};

‎crates/swc_css_minifier/src/compressor/calc_sum.rs

+51-52
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ impl CalcSumContext {
291291
}
292292

293293
fn sum_length(&mut self, operator: Option<&CalcOperator>, operand: &CalcProduct, l: &Length) {
294-
let unit = l.unit.value.to_ascii_lowercase();
295-
if is_absolute_length(unit) {
294+
if is_absolute_length(&l.unit.value) {
296295
self.sum_absolute_length(operator, operand, l)
297296
} else {
298297
self.sum_other_length(operator, operand, l)
@@ -310,17 +309,17 @@ impl CalcSumContext {
310309
operator: prev_operator,
311310
operand: IndexedData { pos, data },
312311
}) => {
313-
let prev_unit = data.unit.value.to_ascii_lowercase();
314-
let unit = l.unit.value.to_ascii_lowercase();
315-
if let Some(result) = get_absolute_length_ratio(prev_unit, unit).and_then(|ratio| {
316-
CalcSumContext::try_to_sum_values(
317-
prev_operator.as_ref(),
318-
operator,
319-
data.value.value,
320-
l.value.value,
321-
Some(ratio),
322-
)
323-
}) {
312+
if let Some(result) = get_absolute_length_ratio(&data.unit.value, &l.unit.value)
313+
.and_then(|ratio| {
314+
CalcSumContext::try_to_sum_values(
315+
prev_operator.as_ref(),
316+
operator,
317+
data.value.value,
318+
l.value.value,
319+
Some(ratio),
320+
)
321+
})
322+
{
324323
data.value.value = result;
325324

326325
CalcSumContext::switch_sign_if_needed(
@@ -351,8 +350,7 @@ impl CalcSumContext {
351350
operand: &CalcProduct,
352351
l: &Length,
353352
) {
354-
let unit = l.unit.value.to_ascii_lowercase();
355-
match &mut self.other_lengths.get_mut(&unit) {
353+
match &mut self.other_lengths.get_mut(&l.unit.value) {
356354
Some(IndexedOperatorAndOperand {
357355
operator: prev_operator,
358356
operand: IndexedData { pos, data },
@@ -384,7 +382,8 @@ impl CalcSumContext {
384382
None => {
385383
let indexed_data: IndexedOperatorAndOperand<Length> =
386384
self.new_indexed_data(operator, operand, l.clone());
387-
self.other_lengths.insert(unit, indexed_data);
385+
self.other_lengths
386+
.insert(l.unit.value.clone(), indexed_data);
388387
}
389388
}
390389
}
@@ -430,17 +429,17 @@ impl CalcSumContext {
430429
operator: prev_operator,
431430
operand: IndexedData { pos, data },
432431
}) => {
433-
let prev_unit = data.unit.value.to_ascii_lowercase();
434-
let unit = d.unit.value.to_ascii_lowercase();
435-
if let Some(result) = get_duration_ratio(prev_unit, unit).and_then(|ratio| {
436-
CalcSumContext::try_to_sum_values(
437-
prev_operator.as_ref(),
438-
operator,
439-
data.value.value,
440-
d.value.value,
441-
Some(ratio),
442-
)
443-
}) {
432+
if let Some(result) =
433+
get_duration_ratio(&data.unit.value, &d.unit.value).and_then(|ratio| {
434+
CalcSumContext::try_to_sum_values(
435+
prev_operator.as_ref(),
436+
operator,
437+
data.value.value,
438+
d.value.value,
439+
Some(ratio),
440+
)
441+
})
442+
{
444443
data.value.value = result;
445444

446445
CalcSumContext::switch_sign_if_needed(
@@ -474,17 +473,17 @@ impl CalcSumContext {
474473
operator: prev_operator,
475474
operand: IndexedData { pos, data },
476475
}) => {
477-
let prev_unit = data.unit.value.to_ascii_lowercase();
478-
let unit = f.unit.value.to_ascii_lowercase();
479-
if let Some(result) = get_frequency_ratio(prev_unit, unit).and_then(|ratio| {
480-
CalcSumContext::try_to_sum_values(
481-
prev_operator.as_ref(),
482-
operator,
483-
data.value.value,
484-
f.value.value,
485-
Some(ratio),
486-
)
487-
}) {
476+
if let Some(result) =
477+
get_frequency_ratio(&data.unit.value, &f.unit.value).and_then(|ratio| {
478+
CalcSumContext::try_to_sum_values(
479+
prev_operator.as_ref(),
480+
operator,
481+
data.value.value,
482+
f.value.value,
483+
Some(ratio),
484+
)
485+
})
486+
{
488487
data.value.value = result;
489488

490489
CalcSumContext::switch_sign_if_needed(
@@ -518,17 +517,17 @@ impl CalcSumContext {
518517
operator: prev_operator,
519518
operand: IndexedData { pos, data },
520519
}) => {
521-
let prev_unit = data.unit.value.to_ascii_lowercase();
522-
let unit = r.unit.value.to_ascii_lowercase();
523-
if let Some(result) = get_resolution_ratio(prev_unit, unit).and_then(|ratio| {
524-
CalcSumContext::try_to_sum_values(
525-
prev_operator.as_ref(),
526-
operator,
527-
data.value.value,
528-
r.value.value,
529-
Some(ratio),
530-
)
531-
}) {
520+
if let Some(result) = get_resolution_ratio(&data.unit.value, &r.unit.value)
521+
.and_then(|ratio| {
522+
CalcSumContext::try_to_sum_values(
523+
prev_operator.as_ref(),
524+
operator,
525+
data.value.value,
526+
r.value.value,
527+
Some(ratio),
528+
)
529+
})
530+
{
532531
data.value.value = result;
533532

534533
CalcSumContext::switch_sign_if_needed(
@@ -591,8 +590,7 @@ impl CalcSumContext {
591590
operand: &CalcProduct,
592591
u: &UnknownDimension,
593592
) {
594-
let unit = u.unit.value.to_ascii_lowercase();
595-
match &mut self.unknown_dimension.get_mut(&unit) {
593+
match &mut self.unknown_dimension.get_mut(&u.unit.value) {
596594
Some(IndexedOperatorAndOperand {
597595
operator: prev_operator,
598596
operand: IndexedData { pos, data },
@@ -625,7 +623,8 @@ impl CalcSumContext {
625623
None => {
626624
let indexed_data: IndexedOperatorAndOperand<UnknownDimension> =
627625
self.new_indexed_data(operator, operand, u.clone());
628-
self.unknown_dimension.insert(unit, indexed_data);
626+
self.unknown_dimension
627+
.insert(u.unit.value.clone(), indexed_data);
629628
}
630629
}
631630
}

‎crates/swc_css_minifier/src/compressor/color.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl Compressor {
324324
unit: Ident { value: unit, .. },
325325
..
326326
}) => {
327-
let angel_type = match get_angle_type(&unit.to_ascii_lowercase()) {
327+
let angel_type = match get_angle_type(unit) {
328328
Some(angel_type) => angel_type,
329329
_ => return None,
330330
};

‎crates/swc_css_minifier/src/compressor/declaration.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,7 @@ impl Compressor {
536536
unit: unit_2,
537537
..
538538
}))),
539-
) if value_1.value == value_2.value
540-
&& unit_1.value.eq_ignore_ascii_case(&unit_2.value) =>
541-
{
542-
true
543-
}
539+
) if value_1.value == value_2.value && unit_1.value == unit_2.value => true,
544540
(
545541
Some(ComponentValue::Integer(box Integer { value: 0, .. })),
546542
Some(ComponentValue::Integer(box Integer { value: 0, .. })),
@@ -576,11 +572,7 @@ impl Compressor {
576572
unit: unit_2,
577573
..
578574
}))),
579-
) if value_1.value == value_2.value
580-
&& unit_1.value.eq_ignore_ascii_case(&unit_2.value) =>
581-
{
582-
true
583-
}
575+
) if value_1.value == value_2.value && unit_1.value == unit_2.value => true,
584576
(
585577
Some(ComponentValue::Percentage(box Percentage { value: value_1, .. })),
586578
Some(ComponentValue::Percentage(box Percentage { value: value_2, .. })),

‎crates/swc_css_minifier/src/compressor/frequency.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::Compressor;
55

66
impl Compressor {
77
pub(super) fn compress_frequency(&mut self, frequency: &mut Frequency) {
8-
match frequency.unit.value.to_ascii_lowercase() {
8+
match frequency.unit.value {
99
js_word!("hz")
1010
if frequency.value.value > 0.0 && frequency.value.value % 1000.0 == 0.0 =>
1111
{

‎crates/swc_css_minifier/src/compressor/length.rs

+20-21
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use swc_css_ast::*;
44
use super::Compressor;
55

66
impl Compressor {
7-
fn convert_length(&mut self, value: f64, from_unit: JsWord, to_unit: JsWord) -> f64 {
8-
match to_unit {
9-
js_word!("cm") => match from_unit {
7+
fn convert_length(&mut self, value: f64, from_unit: &JsWord, to_unit: &JsWord) -> f64 {
8+
match *to_unit {
9+
js_word!("cm") => match *from_unit {
1010
js_word!("cm") => value,
1111
js_word!("mm") => value / 10.0,
1212
js_word!("q") => value / 40.0,
@@ -18,7 +18,7 @@ impl Compressor {
1818
unreachable!()
1919
}
2020
},
21-
js_word!("mm") => match from_unit {
21+
js_word!("mm") => match *from_unit {
2222
js_word!("cm") => 10.0 * value,
2323
js_word!("mm") => value,
2424
js_word!("q") => value / 4.0,
@@ -30,7 +30,7 @@ impl Compressor {
3030
unreachable!()
3131
}
3232
},
33-
js_word!("q") => match from_unit {
33+
js_word!("q") => match *from_unit {
3434
js_word!("cm") => 40.0 * value,
3535
js_word!("mm") => 4.0 * value,
3636
js_word!("q") => value,
@@ -42,7 +42,7 @@ impl Compressor {
4242
unreachable!()
4343
}
4444
},
45-
js_word!("in") => match from_unit {
45+
js_word!("in") => match *from_unit {
4646
js_word!("cm") => value / 2.54,
4747
js_word!("mm") => value / 25.4,
4848
js_word!("q") => value / 101.6,
@@ -54,7 +54,7 @@ impl Compressor {
5454
unreachable!()
5555
}
5656
},
57-
js_word!("pc") => match from_unit {
57+
js_word!("pc") => match *from_unit {
5858
js_word!("cm") => 6.0 / 2.54 * value,
5959
js_word!("mm") => 6.0 / 25.4 * value,
6060
js_word!("q") => 6.0 / 101.6 * value,
@@ -66,7 +66,7 @@ impl Compressor {
6666
unreachable!()
6767
}
6868
},
69-
js_word!("pt") => match from_unit {
69+
js_word!("pt") => match *from_unit {
7070
js_word!("cm") => 72.0 / 2.54 * value,
7171
js_word!("mm") => 72.0 / 25.4 * value,
7272
js_word!("q") => 72.0 / 101.6 * value,
@@ -78,7 +78,7 @@ impl Compressor {
7878
unreachable!()
7979
}
8080
},
81-
js_word!("px") => match from_unit {
81+
js_word!("px") => match *from_unit {
8282
js_word!("cm") => 96.0 / 2.54 * value,
8383
js_word!("mm") => 96.0 / 25.4 * value,
8484
js_word!("q") => 96.0 / 101.6 * value,
@@ -134,13 +134,12 @@ impl Compressor {
134134
}
135135

136136
pub(super) fn compress_length(&mut self, length: &mut Length) {
137-
let from = length.unit.value.to_ascii_lowercase();
138137
let value = length.value.value;
139138

140-
match from {
139+
match length.unit.value {
141140
js_word!("cm") => {
142141
if value % 2.54 == 0.0 {
143-
let new_value = self.convert_length(value, from, js_word!("in"));
142+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("in"));
144143

145144
length.value = Number {
146145
span: length.value.span,
@@ -153,7 +152,7 @@ impl Compressor {
153152
raw: None,
154153
};
155154
} else if value <= 0.1 {
156-
let new_value = self.convert_length(value, from, js_word!("mm"));
155+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("mm"));
157156

158157
length.value = Number {
159158
span: length.value.span,
@@ -169,7 +168,7 @@ impl Compressor {
169168
}
170169
js_word!("mm") => {
171170
if value % 25.4 == 0.0 {
172-
let new_value = self.convert_length(value, from, js_word!("in"));
171+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("in"));
173172

174173
length.value = Number {
175174
span: length.value.span,
@@ -182,7 +181,7 @@ impl Compressor {
182181
raw: None,
183182
};
184183
} else if value % 10.0 == 0.0 {
185-
let new_value = self.convert_length(value, from, js_word!("cm"));
184+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("cm"));
186185

187186
length.value = Number {
188187
span: length.value.span,
@@ -198,7 +197,7 @@ impl Compressor {
198197
}
199198
js_word!("q") => {
200199
if value > 80.0 && value % 40.0 == 0.0 {
201-
let new_value = self.convert_length(value, from, js_word!("cm"));
200+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("cm"));
202201

203202
length.value = Number {
204203
span: length.value.span,
@@ -211,7 +210,7 @@ impl Compressor {
211210
raw: None,
212211
};
213212
} else if value % 101.6 == 0.0 {
214-
let new_value = self.convert_length(value, from, js_word!("in"));
213+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("in"));
215214

216215
length.value = Number {
217216
span: length.value.span,
@@ -227,7 +226,7 @@ impl Compressor {
227226
}
228227
js_word!("pc") => {
229228
if value % 6.0 == 0.0 {
230-
let new_value = self.convert_length(value, from, js_word!("in"));
229+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("in"));
231230

232231
length.value = Number {
233232
span: length.value.span,
@@ -243,7 +242,7 @@ impl Compressor {
243242
}
244243
js_word!("pt") => {
245244
if value % 72.0 == 0.0 {
246-
let new_value = self.convert_length(value, from, js_word!("in"));
245+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("in"));
247246

248247
length.value = Number {
249248
span: length.value.span,
@@ -256,7 +255,7 @@ impl Compressor {
256255
raw: None,
257256
};
258257
} else if value % 12.0 == 0.0 {
259-
let new_value = self.convert_length(value, from, js_word!("pc"));
258+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("pc"));
260259

261260
length.value = Number {
262261
span: length.value.span,
@@ -269,7 +268,7 @@ impl Compressor {
269268
raw: None,
270269
};
271270
} else if value % 0.75 == 0.0 {
272-
let new_value = self.convert_length(value, from, js_word!("px"));
271+
let new_value = self.convert_length(value, &length.unit.value, &js_word!("px"));
273272

274273
length.value = Number {
275274
span: length.value.span,

‎crates/swc_css_minifier/src/compressor/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::Compressor;
55

66
impl Compressor {
77
pub(super) fn compress_time(&self, time: &mut Time) {
8-
match time.unit.value.to_ascii_lowercase() {
8+
match time.unit.value {
99
js_word!("ms") if time.value.value == 0.0 || time.value.value >= 100.0 => {
1010
let new_value = time.value.value / 1000.0;
1111

‎crates/swc_css_minifier/src/compressor/unit/mod.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
11
use swc_atoms::{js_word, JsWord};
22

3-
pub fn get_duration_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
3+
pub fn get_duration_ratio(unit1: &JsWord, unit2: &JsWord) -> Option<f64> {
44
// Duration ratio, see https://www.w3.org/TR/css-values-4/#time
55

66
if unit1 == unit2 {
77
return Some(1.0);
88
}
99

10-
match unit1 {
11-
js_word!("ms") => match unit2 {
10+
match *unit1 {
11+
js_word!("ms") => match *unit2 {
1212
js_word!("s") => Some(1000.0),
1313
_ => None,
1414
},
15-
js_word!("s") => match unit2 {
15+
js_word!("s") => match *unit2 {
1616
js_word!("ms") => Some(0.001),
1717
_ => None,
1818
},
1919
_ => None,
2020
}
2121
}
2222

23-
pub fn get_frequency_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
23+
pub fn get_frequency_ratio(unit1: &JsWord, unit2: &JsWord) -> Option<f64> {
2424
// Frequency ratio, see https://www.w3.org/TR/css-values-4/#frequency
2525

2626
if unit1 == unit2 {
2727
return Some(1.0);
2828
}
2929

30-
match unit1 {
31-
js_word!("hz") => match unit2 {
30+
match *unit1 {
31+
js_word!("hz") => match *unit2 {
3232
js_word!("khz") => Some(1000.0),
3333
_ => None,
3434
},
35-
js_word!("khz") => match unit2 {
35+
js_word!("khz") => match *unit2 {
3636
js_word!("hz") => Some(0.001),
3737
_ => None,
3838
},
3939
_ => None,
4040
}
4141
}
4242

43-
pub fn get_absolute_length_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
43+
pub fn get_absolute_length_ratio(unit1: &JsWord, unit2: &JsWord) -> Option<f64> {
4444
// For length ratio, see https://www.w3.org/TR/css-values-4/#absolute-lengths
4545

4646
if unit1 == unit2 {
4747
return Some(1.0);
4848
}
4949

50-
match unit1 {
51-
js_word!("cm") => match unit2 {
50+
match *unit1 {
51+
js_word!("cm") => match *unit2 {
5252
js_word!("mm") => Some(0.1),
5353
js_word!("q") => Some(0.025),
5454
js_word!("in") => Some(2.54),
5555
_ => None,
5656
},
57-
js_word!("mm") => match unit2 {
57+
js_word!("mm") => match *unit2 {
5858
js_word!("cm") => Some(10.0),
5959
js_word!("q") => Some(0.25),
6060
js_word!("in") => Some(25.4),
6161
_ => None,
6262
},
63-
js_word!("q") => match unit2 {
63+
js_word!("q") => match *unit2 {
6464
js_word!("cm") => Some(40.0),
6565
js_word!("mm") => Some(4.0),
6666
js_word!("in") => Some(101.6),
6767
_ => None,
6868
},
69-
js_word!("pc") => match unit2 {
69+
js_word!("pc") => match *unit2 {
7070
js_word!("in") => Some(6.0),
7171
js_word!("px") => Some(0.0625),
7272
_ => None,
7373
},
74-
js_word!("pt") => match unit2 {
74+
js_word!("pt") => match *unit2 {
7575
js_word!("in") => Some(72.0),
7676
js_word!("pc") => Some(12.0),
7777
js_word!("px") => Some(0.75),
7878
_ => None,
7979
},
80-
js_word!("px") => match unit2 {
80+
js_word!("px") => match *unit2 {
8181
js_word!("in") => Some(96.0),
8282
js_word!("pc") => Some(16.0),
8383
_ => None,
@@ -86,20 +86,20 @@ pub fn get_absolute_length_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
8686
}
8787
}
8888

89-
pub fn get_resolution_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
89+
pub fn get_resolution_ratio(unit1: &JsWord, unit2: &JsWord) -> Option<f64> {
9090
// Resolution ratio, see https://www.w3.org/TR/css-values-4/#resolution
9191
// "x" is an alias for "dppx"
9292

9393
if unit1 == unit2 {
9494
return Some(1.0);
9595
}
9696

97-
match unit1 {
98-
js_word!("dpcm") => match unit2 {
97+
match *unit1 {
98+
js_word!("dpcm") => match *unit2 {
9999
js_word!("dpi") => Some(2.54),
100100
_ => None,
101101
},
102-
js_word!("dppx") | js_word!("x") => match unit2 {
102+
js_word!("dppx") | js_word!("x") => match *unit2 {
103103
js_word!("dppx") | js_word!("x") => Some(1.0),
104104
js_word!("dpi") => Some(96.0),
105105
_ => None,
@@ -108,8 +108,8 @@ pub fn get_resolution_ratio(unit1: JsWord, unit2: JsWord) -> Option<f64> {
108108
}
109109
}
110110

111-
pub fn is_absolute_length(unit: JsWord) -> bool {
112-
match unit {
111+
pub fn is_absolute_length(unit: &JsWord) -> bool {
112+
match *unit {
113113
js_word!("cm")
114114
| js_word!("mm")
115115
| js_word!("q")

‎crates/swc_css_minifier/tests/fixture/compress-calc/simple-calc/output.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc_css_parser/src/parser/values_and_units/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2004,7 +2004,7 @@ where
20042004
},
20052005
unit: Ident {
20062006
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2007-
value: unit,
2007+
value: unit.to_ascii_lowercase(),
20082008
raw: Some(raw_unit),
20092009
},
20102010
})
@@ -2053,7 +2053,7 @@ where
20532053
},
20542054
unit: Ident {
20552055
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2056-
value: unit,
2056+
value: unit.to_ascii_lowercase(),
20572057
raw: Some(raw_unit),
20582058
},
20592059
})
@@ -2099,7 +2099,7 @@ where
20992099
},
21002100
unit: Ident {
21012101
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2102-
value: unit,
2102+
value: unit.to_ascii_lowercase(),
21032103
raw: Some(raw_unit),
21042104
},
21052105
})
@@ -2145,7 +2145,7 @@ where
21452145
},
21462146
unit: Ident {
21472147
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2148-
value: unit,
2148+
value: unit.to_ascii_lowercase(),
21492149
raw: Some(raw_unit),
21502150
},
21512151
})
@@ -2194,7 +2194,7 @@ where
21942194
},
21952195
unit: Ident {
21962196
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2197-
value: unit,
2197+
value: unit.to_ascii_lowercase(),
21982198
raw: Some(raw_unit),
21992199
},
22002200
})
@@ -2240,7 +2240,7 @@ where
22402240
},
22412241
unit: Ident {
22422242
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2243-
value: unit,
2243+
value: unit.to_ascii_lowercase(),
22442244
raw: Some(raw_unit),
22452245
},
22462246
})
@@ -2282,7 +2282,7 @@ where
22822282
},
22832283
unit: Ident {
22842284
span: Span::new(span.hi - BytePos(unit_len), span.hi, Default::default()),
2285-
value: unit,
2285+
value: unit.to_lowercase().into(),
22862286
raw: Some(raw_unit),
22872287
},
22882288
})

‎crates/swc_css_parser/tests/fixture/at-rule/import/output.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9361,7 +9361,7 @@
93619361
"end": 4817,
93629362
"ctxt": 0
93639363
},
9364-
"value": "PX",
9364+
"value": "px",
93659365
"raw": "PX"
93669366
}
93679367
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
div {
22
width: 100\%;
33
width: 100px2p;
4+
width: 100px;
5+
width: 100PX;
6+
width: 100UNKNOWN;
7+
width: 100НЕИЗВЕСТНО;
48
}

‎crates/swc_css_parser/tests/fixture/value/dimension/output.json

+199-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"type": "Stylesheet",
33
"span": {
44
"start": 1,
5-
"end": 47,
5+
"end": 142,
66
"ctxt": 0
77
},
88
"rules": [
99
{
1010
"type": "QualifiedRule",
1111
"span": {
1212
"start": 1,
13-
"end": 46,
13+
"end": 141,
1414
"ctxt": 0
1515
},
1616
"prelude": {
@@ -74,7 +74,7 @@
7474
"type": "SimpleBlock",
7575
"span": {
7676
"start": 5,
77-
"end": 46,
77+
"end": 141,
7878
"ctxt": 0
7979
},
8080
"name": {
@@ -184,6 +184,202 @@
184184
}
185185
],
186186
"important": null
187+
},
188+
{
189+
"type": "Declaration",
190+
"span": {
191+
"start": 49,
192+
"end": 61,
193+
"ctxt": 0
194+
},
195+
"name": {
196+
"type": "Ident",
197+
"span": {
198+
"start": 49,
199+
"end": 54,
200+
"ctxt": 0
201+
},
202+
"value": "width",
203+
"raw": "width"
204+
},
205+
"value": [
206+
{
207+
"type": "Length",
208+
"span": {
209+
"start": 56,
210+
"end": 61,
211+
"ctxt": 0
212+
},
213+
"value": {
214+
"type": "Number",
215+
"span": {
216+
"start": 56,
217+
"end": 59,
218+
"ctxt": 0
219+
},
220+
"value": 100.0,
221+
"raw": "100"
222+
},
223+
"unit": {
224+
"type": "Ident",
225+
"span": {
226+
"start": 59,
227+
"end": 61,
228+
"ctxt": 0
229+
},
230+
"value": "px",
231+
"raw": "px"
232+
}
233+
}
234+
],
235+
"important": null
236+
},
237+
{
238+
"type": "Declaration",
239+
"span": {
240+
"start": 67,
241+
"end": 79,
242+
"ctxt": 0
243+
},
244+
"name": {
245+
"type": "Ident",
246+
"span": {
247+
"start": 67,
248+
"end": 72,
249+
"ctxt": 0
250+
},
251+
"value": "width",
252+
"raw": "width"
253+
},
254+
"value": [
255+
{
256+
"type": "Length",
257+
"span": {
258+
"start": 74,
259+
"end": 79,
260+
"ctxt": 0
261+
},
262+
"value": {
263+
"type": "Number",
264+
"span": {
265+
"start": 74,
266+
"end": 77,
267+
"ctxt": 0
268+
},
269+
"value": 100.0,
270+
"raw": "100"
271+
},
272+
"unit": {
273+
"type": "Ident",
274+
"span": {
275+
"start": 77,
276+
"end": 79,
277+
"ctxt": 0
278+
},
279+
"value": "px",
280+
"raw": "PX"
281+
}
282+
}
283+
],
284+
"important": null
285+
},
286+
{
287+
"type": "Declaration",
288+
"span": {
289+
"start": 85,
290+
"end": 102,
291+
"ctxt": 0
292+
},
293+
"name": {
294+
"type": "Ident",
295+
"span": {
296+
"start": 85,
297+
"end": 90,
298+
"ctxt": 0
299+
},
300+
"value": "width",
301+
"raw": "width"
302+
},
303+
"value": [
304+
{
305+
"type": "UnknownDimension",
306+
"span": {
307+
"start": 92,
308+
"end": 102,
309+
"ctxt": 0
310+
},
311+
"value": {
312+
"type": "Number",
313+
"span": {
314+
"start": 92,
315+
"end": 95,
316+
"ctxt": 0
317+
},
318+
"value": 100.0,
319+
"raw": "100"
320+
},
321+
"unit": {
322+
"type": "Ident",
323+
"span": {
324+
"start": 95,
325+
"end": 102,
326+
"ctxt": 0
327+
},
328+
"value": "unknown",
329+
"raw": "UNKNOWN"
330+
}
331+
}
332+
],
333+
"important": null
334+
},
335+
{
336+
"type": "Declaration",
337+
"span": {
338+
"start": 108,
339+
"end": 138,
340+
"ctxt": 0
341+
},
342+
"name": {
343+
"type": "Ident",
344+
"span": {
345+
"start": 108,
346+
"end": 113,
347+
"ctxt": 0
348+
},
349+
"value": "width",
350+
"raw": "width"
351+
},
352+
"value": [
353+
{
354+
"type": "UnknownDimension",
355+
"span": {
356+
"start": 115,
357+
"end": 138,
358+
"ctxt": 0
359+
},
360+
"value": {
361+
"type": "Number",
362+
"span": {
363+
"start": 115,
364+
"end": 118,
365+
"ctxt": 0
366+
},
367+
"value": 100.0,
368+
"raw": "100"
369+
},
370+
"unit": {
371+
"type": "Ident",
372+
"span": {
373+
"start": 118,
374+
"end": 138,
375+
"ctxt": 0
376+
},
377+
"value": "неизвестно",
378+
"raw": "НЕИЗВЕСТНО"
379+
}
380+
}
381+
],
382+
"important": null
187383
}
188384
]
189385
}

‎crates/swc_css_parser/tests/fixture/value/dimension/span.swc-stderr

+317-13
Large diffs are not rendered by default.

‎crates/swc_css_parser/tests/fixture/value/frequency/output.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"end": 20,
130130
"ctxt": 0
131131
},
132-
"value": "Hz",
132+
"value": "hz",
133133
"raw": "Hz"
134134
}
135135
}
@@ -178,7 +178,7 @@
178178
"end": 36,
179179
"ctxt": 0
180180
},
181-
"value": "kHz",
181+
"value": "khz",
182182
"raw": "kHz"
183183
}
184184
}

‎crates/swc_css_parser/tests/fixture/value/length/output.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
"end": 78,
277277
"ctxt": 0
278278
},
279-
"value": "PX",
279+
"value": "px",
280280
"raw": "PX"
281281
}
282282
}
@@ -325,7 +325,7 @@
325325
"end": 96,
326326
"ctxt": 0
327327
},
328-
"value": "pX",
328+
"value": "px",
329329
"raw": "pX"
330330
}
331331
}

‎crates/swc_css_prefixer/src/prefixer.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,11 @@ impl VisitMut for MediaFeatureResolutionReplacerOnLegacyVariant<'_> {
492492
raw: None,
493493
});
494494

495-
let left = match &*resolution_unit.value.to_ascii_lowercase() {
496-
"dpi" => (resolution_value.value / 96.0 * 100.0).round() / 100.0,
497-
"dpcm" => (((resolution_value.value * 2.54) / 96.0) * 100.0).round() / 100.0,
495+
let left = match resolution_unit.value {
496+
js_word!("dpi") => (resolution_value.value / 96.0 * 100.0).round() / 100.0,
497+
js_word!("dpcm") => {
498+
(((resolution_value.value * 2.54) / 96.0) * 100.0).round() / 100.0
499+
}
498500
_ => resolution_value.value,
499501
};
500502

‎crates/swc_css_prefixer/tests/fixture/gradient/input.css

+4
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,7 @@ div {
159159
.zero-turn {
160160
background: linear-gradient(0turn, green, blue);
161161
}
162+
163+
a {
164+
background: linear-gradient(350.5DEG, white, black), linear-gradient(-130DEG, black, white), linear-gradient(45DEG, black, white);
165+
}

‎crates/swc_css_prefixer/tests/fixture/gradient/output.css

+6
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,9 @@ div {
261261
background: -o-linear-gradient(bottom, green, blue);
262262
background: linear-gradient(0turn, green, blue);
263263
}
264+
a {
265+
background: -webkit-linear-gradient(99.5deg, white, black), -webkit-linear-gradient(220deg, black, white), -webkit-linear-gradient(45deg, black, white);
266+
background: -moz-linear-gradient(99.5deg, white, black), -moz-linear-gradient(220deg, black, white), -moz-linear-gradient(45deg, black, white);
267+
background: -o-linear-gradient(99.5deg, white, black), -o-linear-gradient(220deg, black, white), -o-linear-gradient(45deg, black, white);
268+
background: linear-gradient(350.5DEG, white, black), linear-gradient(-130DEG, black, white), linear-gradient(45DEG, black, white);
269+
}

‎crates/swc_css_prefixer/tests/fixture/gradient/output.defaults-not-ie-11.css

+3
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,6 @@ div {
123123
.zero-turn {
124124
background: linear-gradient(0turn, green, blue);
125125
}
126+
a {
127+
background: linear-gradient(350.5DEG, white, black), linear-gradient(-130DEG, black, white), linear-gradient(45DEG, black, white);
128+
}

‎crates/swc_css_prefixer/tests/fixture/resolution/input.css

+7-1
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,10 @@
9696

9797
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (min-resolution: 2dppx) {}
9898

99-
@media (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2) {}
99+
@media (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2) {}
100+
101+
@media (min-resolution: 113.38DPCM) {
102+
.class {
103+
color: red;
104+
}
105+
}

‎crates/swc_css_prefixer/tests/fixture/resolution/output.css

+5
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,8 @@
8888
@media (min-resolution: 113.38dpcm), (-webkit-min-device-pixel-ratio: 3), (min--moz-device-pixel-ratio: 3) {}
8989
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (min-resolution: 2dppx) {}
9090
@media (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2) {}
91+
@media (min-resolution: 113.38DPCM), (-webkit-min-device-pixel-ratio: 3), (min--moz-device-pixel-ratio: 3) {
92+
.class {
93+
color: red;
94+
}
95+
}

‎crates/swc_css_prefixer/tests/fixture/resolution/output.defaults-not-ie-11.css

+5
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@
7373
@media (min-resolution: 113.38dpcm), (-webkit-min-device-pixel-ratio: 3) {}
7474
@media (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2), (min-resolution: 2dppx) {}
7575
@media (min-resolution: 2dppx), (-webkit-min-device-pixel-ratio: 2), (min--moz-device-pixel-ratio: 2) {}
76+
@media (min-resolution: 113.38DPCM), (-webkit-min-device-pixel-ratio: 3) {
77+
.class {
78+
color: red;
79+
}
80+
}

1 commit comments

Comments
 (1)

github-actions[bot] commented on Dec 16, 2022

@github-actions[bot]

Benchmark

Benchmark suite Current: 3d3863d Previous: 1fc97a7 Ratio
es/full/bugs-1 309165 ns/iter (± 11188) 311176 ns/iter (± 9808) 0.99
es/full/minify/libraries/antd 1803644781 ns/iter (± 19644694) 1775581873 ns/iter (± 27499485) 1.02
es/full/minify/libraries/d3 324440941 ns/iter (± 4801873) 312728891 ns/iter (± 5383083) 1.04
es/full/minify/libraries/echarts 1381203816 ns/iter (± 11657545) 1363716880 ns/iter (± 9199524) 1.01
es/full/minify/libraries/jquery 94004610 ns/iter (± 863382) 91990533 ns/iter (± 1703350) 1.02
es/full/minify/libraries/lodash 109962930 ns/iter (± 1125769) 108678784 ns/iter (± 562263) 1.01
es/full/minify/libraries/moment 54466010 ns/iter (± 1960930) 53760617 ns/iter (± 220051) 1.01
es/full/minify/libraries/react 19367399 ns/iter (± 101522) 19298838 ns/iter (± 140954) 1.00
es/full/minify/libraries/terser 272368492 ns/iter (± 3390504) 262343731 ns/iter (± 2772658) 1.04
es/full/minify/libraries/three 490547481 ns/iter (± 7223233) 479505586 ns/iter (± 10934774) 1.02
es/full/minify/libraries/typescript 3328139453 ns/iter (± 36946273) 3333243105 ns/iter (± 26354226) 1.00
es/full/minify/libraries/victory 762426651 ns/iter (± 12359824) 749094432 ns/iter (± 14544727) 1.02
es/full/minify/libraries/vue 137859285 ns/iter (± 2058655) 134491174 ns/iter (± 1320755) 1.03
es/full/codegen/es3 27693 ns/iter (± 52) 27398 ns/iter (± 73) 1.01
es/full/codegen/es5 27809 ns/iter (± 67) 27474 ns/iter (± 50) 1.01
es/full/codegen/es2015 27708 ns/iter (± 80) 27380 ns/iter (± 47) 1.01
es/full/codegen/es2016 27799 ns/iter (± 78) 27421 ns/iter (± 61) 1.01
es/full/codegen/es2017 27691 ns/iter (± 67) 27398 ns/iter (± 67) 1.01
es/full/codegen/es2018 27763 ns/iter (± 56) 27444 ns/iter (± 71) 1.01
es/full/codegen/es2019 27671 ns/iter (± 44) 27404 ns/iter (± 41) 1.01
es/full/codegen/es2020 27699 ns/iter (± 64) 27385 ns/iter (± 48) 1.01
es/full/all/es3 173557368 ns/iter (± 2978172) 171037184 ns/iter (± 1769984) 1.01
es/full/all/es5 163609562 ns/iter (± 2443079) 162278752 ns/iter (± 1441436) 1.01
es/full/all/es2015 126421647 ns/iter (± 2950440) 121432395 ns/iter (± 1227312) 1.04
es/full/all/es2016 123450121 ns/iter (± 2752297) 120986801 ns/iter (± 1537505) 1.02
es/full/all/es2017 123074278 ns/iter (± 1778446) 120357674 ns/iter (± 1164235) 1.02
es/full/all/es2018 120466390 ns/iter (± 719618) 118428708 ns/iter (± 1265959) 1.02
es/full/all/es2019 120189822 ns/iter (± 1560724) 118075555 ns/iter (± 1620599) 1.02
es/full/all/es2020 115392515 ns/iter (± 1220610) 112930538 ns/iter (± 1116164) 1.02
es/full/parser 517343 ns/iter (± 9347) 515877 ns/iter (± 7226) 1.00
es/full/base/fixer 22225 ns/iter (± 35) 21962 ns/iter (± 42) 1.01
es/full/base/resolver_and_hygiene 78025 ns/iter (± 128) 78497 ns/iter (± 105) 0.99
serialization of ast node 139 ns/iter (± 0) 138 ns/iter (± 0) 1.01
serialization of serde 124 ns/iter (± 0) 124 ns/iter (± 0) 1
css/minify/libraries/bootstrap 27252934 ns/iter (± 634341) 27002188 ns/iter (± 87744) 1.01
css/visitor/compare/clone 2085399 ns/iter (± 20750) 2085060 ns/iter (± 14968) 1.00
css/visitor/compare/visit_mut_span 2305466 ns/iter (± 15850) 2297396 ns/iter (± 7861) 1.00
css/visitor/compare/visit_mut_span_panic 2349001 ns/iter (± 6294) 2382957 ns/iter (± 6375) 0.99
css/visitor/compare/fold_span 3034571 ns/iter (± 30576) 3058284 ns/iter (± 24136) 0.99
css/visitor/compare/fold_span_panic 3176955 ns/iter (± 47988) 3149914 ns/iter (± 26293) 1.01
css/lexer/bootstrap_5_1_3 5349618 ns/iter (± 1865) 5266184 ns/iter (± 6834) 1.02
css/lexer/foundation_6_7_4 4420599 ns/iter (± 1727) 4429143 ns/iter (± 3168) 1.00
css/lexer/tailwind_3_1_1 829417 ns/iter (± 185) 832377 ns/iter (± 1361) 1.00
css/parser/bootstrap_5_1_3 21475844 ns/iter (± 72229) 21087312 ns/iter (± 47860) 1.02
css/parser/foundation_6_7_4 17047445 ns/iter (± 37674) 16788559 ns/iter (± 41054) 1.02
css/parser/tailwind_3_1_1 3250005 ns/iter (± 6288) 3231035 ns/iter (± 10168) 1.01
es/codegen/colors 322873 ns/iter (± 181339) 324875 ns/iter (± 181931) 0.99
es/codegen/large 1219555 ns/iter (± 644558) 1245815 ns/iter (± 633547) 0.98
es/codegen/with-parser/colors 46815 ns/iter (± 310) 46632 ns/iter (± 327) 1.00
es/codegen/with-parser/large 509704 ns/iter (± 3092) 511406 ns/iter (± 1679) 1.00
es/minify/libraries/antd 1573128362 ns/iter (± 31570166) 1565650346 ns/iter (± 26597360) 1.00
es/minify/libraries/d3 276767153 ns/iter (± 5788516) 268500189 ns/iter (± 4810400) 1.03
es/minify/libraries/echarts 1189808687 ns/iter (± 9640247) 1172715515 ns/iter (± 9850203) 1.01
es/minify/libraries/jquery 80646398 ns/iter (± 778064) 79439898 ns/iter (± 727808) 1.02
es/minify/libraries/lodash 98496085 ns/iter (± 1822368) 96970348 ns/iter (± 944225) 1.02
es/minify/libraries/moment 46820351 ns/iter (± 392800) 46974955 ns/iter (± 286344) 1.00
es/minify/libraries/react 17247853 ns/iter (± 183502) 17259795 ns/iter (± 151806) 1.00
es/minify/libraries/terser 231527671 ns/iter (± 6211630) 229933583 ns/iter (± 6011838) 1.01
es/minify/libraries/three 428359845 ns/iter (± 12313762) 399081446 ns/iter (± 9206746) 1.07
es/minify/libraries/typescript 2882676129 ns/iter (± 26121672) 2863139541 ns/iter (± 17888676) 1.01
es/minify/libraries/victory 671625714 ns/iter (± 10636538) 635373240 ns/iter (± 15140259) 1.06
es/minify/libraries/vue 124003669 ns/iter (± 2038454) 118275356 ns/iter (± 1890092) 1.05
es/visitor/compare/clone 2461793 ns/iter (± 61327) 2415176 ns/iter (± 4242) 1.02
es/visitor/compare/visit_mut_span 2817648 ns/iter (± 8659) 2842708 ns/iter (± 12448) 0.99
es/visitor/compare/visit_mut_span_panic 2890846 ns/iter (± 21041) 2888427 ns/iter (± 2894) 1.00
es/visitor/compare/fold_span 4006048 ns/iter (± 53376) 3990125 ns/iter (± 8103) 1.00
es/visitor/compare/fold_span_panic 4154615 ns/iter (± 15564) 4153102 ns/iter (± 12811) 1.00
es/lexer/colors 17260 ns/iter (± 7) 17225 ns/iter (± 31) 1.00
es/lexer/angular 8262840 ns/iter (± 6258) 8235156 ns/iter (± 17667) 1.00
es/lexer/backbone 1077903 ns/iter (± 278) 1072041 ns/iter (± 3376) 1.01
es/lexer/jquery 5983810 ns/iter (± 2497) 5968023 ns/iter (± 8869) 1.00
es/lexer/jquery mobile 9204069 ns/iter (± 10281) 9153202 ns/iter (± 12531) 1.01
es/lexer/mootools 4697022 ns/iter (± 4566) 4666119 ns/iter (± 7013) 1.01
es/lexer/underscore 901198 ns/iter (± 770) 895138 ns/iter (± 882) 1.01
es/lexer/three 28067382 ns/iter (± 14834) 27891988 ns/iter (± 30670) 1.01
es/lexer/yui 5066626 ns/iter (± 2037) 5046241 ns/iter (± 3710) 1.00
es/parser/colors 30970 ns/iter (± 157) 31230 ns/iter (± 203) 0.99
es/parser/angular 16825116 ns/iter (± 272679) 16190056 ns/iter (± 112070) 1.04
es/parser/backbone 2330480 ns/iter (± 16349) 2322015 ns/iter (± 13707) 1.00
es/parser/jquery 12960183 ns/iter (± 562416) 12680558 ns/iter (± 79496) 1.02
es/parser/jquery mobile 21402855 ns/iter (± 378515) 20740007 ns/iter (± 491092) 1.03
es/parser/mootools 9701416 ns/iter (± 45064) 9565262 ns/iter (± 42918) 1.01
es/parser/underscore 1973631 ns/iter (± 11113) 1969532 ns/iter (± 11077) 1.00
es/parser/three 62428764 ns/iter (± 300999) 61050618 ns/iter (± 555638) 1.02
es/parser/yui 9794072 ns/iter (± 62401) 9697221 ns/iter (± 91728) 1.01
es/preset-env/usage/builtin_type 139921 ns/iter (± 35307) 137577 ns/iter (± 30415) 1.02
es/preset-env/usage/property 21110 ns/iter (± 65) 21436 ns/iter (± 51) 0.98
es/resolver/typescript 122120337 ns/iter (± 2737111) 125439841 ns/iter (± 3176794) 0.97
es/fixer/typescript 99989353 ns/iter (± 6070042) 98838469 ns/iter (± 665946) 1.01
es/hygiene/typescript 200874717 ns/iter (± 1227148) 199157525 ns/iter (± 2671069) 1.01
es/resolver_with_hygiene/typescript 349035856 ns/iter (± 2804510) 343830721 ns/iter (± 1792413) 1.02
es/visitor/base-perf/module_clone 75723 ns/iter (± 1813) 76290 ns/iter (± 1619) 0.99
es/visitor/base-perf/fold_empty 85215 ns/iter (± 1897) 85937 ns/iter (± 1822) 0.99
es/visitor/base-perf/fold_noop_impl_all 84901 ns/iter (± 713) 85714 ns/iter (± 2341) 0.99
es/visitor/base-perf/fold_noop_impl_vec 85571 ns/iter (± 1218) 85986 ns/iter (± 1480) 1.00
es/visitor/base-perf/boxing_boxed_clone 59 ns/iter (± 0) 56 ns/iter (± 0) 1.05
es/visitor/base-perf/boxing_unboxed_clone 59 ns/iter (± 0) 59 ns/iter (± 0) 1
es/visitor/base-perf/boxing_boxed 103 ns/iter (± 0) 102 ns/iter (± 0) 1.01
es/visitor/base-perf/boxing_unboxed 106 ns/iter (± 0) 102 ns/iter (± 0) 1.04
es/visitor/base-perf/visit_contains_this 3399 ns/iter (± 67) 3641 ns/iter (± 113) 0.93
es/base/parallel/resolver/typescript 5064855948 ns/iter (± 423579931) 5635989023 ns/iter (± 492243651) 0.90
es/base/parallel/hygiene/typescript 2249873077 ns/iter (± 40928411) 2298814593 ns/iter (± 36261400) 0.98
misc/visitors/time-complexity/time 5 93 ns/iter (± 1) 93 ns/iter (± 0) 1
misc/visitors/time-complexity/time 10 327 ns/iter (± 3) 324 ns/iter (± 0) 1.01
misc/visitors/time-complexity/time 15 635 ns/iter (± 2) 646 ns/iter (± 10) 0.98
misc/visitors/time-complexity/time 20 1191 ns/iter (± 1) 1192 ns/iter (± 1) 1.00
misc/visitors/time-complexity/time 40 6150 ns/iter (± 1) 6183 ns/iter (± 12) 0.99
misc/visitors/time-complexity/time 60 15496 ns/iter (± 7) 15528 ns/iter (± 17) 1.00
es/full-target/es2016 188367 ns/iter (± 1145) 188881 ns/iter (± 383) 1.00
es/full-target/es2017 183716 ns/iter (± 538) 183356 ns/iter (± 492) 1.00
es/full-target/es2018 172448 ns/iter (± 820) 171819 ns/iter (± 436) 1.00
es2020_nullish_coalescing 66931 ns/iter (± 106) 66687 ns/iter (± 144) 1.00
es2020_optional_chaining 96014 ns/iter (± 5564) 95459 ns/iter (± 4563) 1.01
es2022_class_properties 93345 ns/iter (± 162) 93574 ns/iter (± 262) 1.00
es2018_object_rest_spread 70302 ns/iter (± 101) 71464 ns/iter (± 175) 0.98
es2019_optional_catch_binding 60148 ns/iter (± 89) 61066 ns/iter (± 161) 0.98
es2017_async_to_generator 60462 ns/iter (± 87) 61567 ns/iter (± 90) 0.98
es2016_exponentiation 63780 ns/iter (± 150) 64951 ns/iter (± 116) 0.98
es2015_arrow 68378 ns/iter (± 116) 70366 ns/iter (± 210) 0.97
es2015_block_scoped_fn 64400 ns/iter (± 63) 65986 ns/iter (± 122) 0.98
es2015_block_scoping 147650 ns/iter (± 9295) 138896 ns/iter (± 6716) 1.06
es2015_classes 113822 ns/iter (± 468) 117385 ns/iter (± 502) 0.97
es2015_computed_props 59686 ns/iter (± 106) 61081 ns/iter (± 148) 0.98
es2015_destructuring 112944 ns/iter (± 104) 116261 ns/iter (± 270) 0.97
es2015_duplicate_keys 62614 ns/iter (± 70) 63700 ns/iter (± 167) 0.98
es2015_parameters 78187 ns/iter (± 164) 79293 ns/iter (± 118) 0.99
es2015_fn_name 65771 ns/iter (± 652) 67068 ns/iter (± 597) 0.98
es2015_for_of 62769 ns/iter (± 84) 64388 ns/iter (± 197) 0.97
es2015_instanceof 62252 ns/iter (± 77) 63472 ns/iter (± 176) 0.98
es2015_shorthand_property 59982 ns/iter (± 67) 60688 ns/iter (± 66) 0.99
es2015_spread 59960 ns/iter (± 59) 60794 ns/iter (± 111) 0.99
es2015_sticky_regex 61262 ns/iter (± 41) 62257 ns/iter (± 146) 0.98
es2015_typeof_symbol 61241 ns/iter (± 73) 62137 ns/iter (± 143) 0.99
es/transform/baseline/base 51044 ns/iter (± 88) 51738 ns/iter (± 103) 0.99
es/transform/baseline/common_reserved_word 61319 ns/iter (± 82) 62332 ns/iter (± 112) 0.98
es/transform/baseline/common_typescript 166559 ns/iter (± 376) 155484 ns/iter (± 10505) 1.07
es/target/es3 165804 ns/iter (± 122) 168700 ns/iter (± 321) 0.98
es/target/es2015 602001 ns/iter (± 1149) 630900 ns/iter (± 902) 0.95
es/target/es2016 63778 ns/iter (± 76) 64994 ns/iter (± 72) 0.98
es/target/es2017 60452 ns/iter (± 45) 61618 ns/iter (± 114) 0.98
es/target/es2018 80204 ns/iter (± 73) 81371 ns/iter (± 133) 0.99
es/target/es2020 128441 ns/iter (± 115) 132505 ns/iter (± 276) 0.97
babelify-only 671031 ns/iter (± 1482) 675352 ns/iter (± 1283) 0.99
parse_and_babelify_angular 45899029 ns/iter (± 721333) 42497160 ns/iter (± 839117) 1.08
parse_and_babelify_backbone 5649894 ns/iter (± 161103) 5510516 ns/iter (± 63817) 1.03
parse_and_babelify_jquery 34577922 ns/iter (± 503362) 33558777 ns/iter (± 390548) 1.03
parse_and_babelify_jquery_mobile 59465545 ns/iter (± 1000709) 57724765 ns/iter (± 657042) 1.03
parse_and_babelify_mootools 35631671 ns/iter (± 383767) 35086916 ns/iter (± 460985) 1.02
parse_and_babelify_underscore 4392093 ns/iter (± 37491) 4392479 ns/iter (± 41487) 1.00
parse_and_babelify_yui 35439449 ns/iter (± 678210) 35193477 ns/iter (± 616657) 1.01
html/minify/document/css_spec 43375156 ns/iter (± 263807) 42873073 ns/iter (± 314228) 1.01
html/minify/document/github 17735859 ns/iter (± 345661) 17709914 ns/iter (± 40382) 1.00
html/minify/document/stackoverflow 15690098 ns/iter (± 42669) 15626896 ns/iter (± 44190) 1.00
html/minify/document_fragment/css_spec 41736730 ns/iter (± 358376) 41142457 ns/iter (± 180003) 1.01
html/minify/document_fragment/github 17083201 ns/iter (± 28754) 16812405 ns/iter (± 27576) 1.02
html/minify/document_fragment/stackoverflow 15338205 ns/iter (± 83196) 15154728 ns/iter (± 41787) 1.01
html/document/visitor/compare/clone 338078 ns/iter (± 2292) 337699 ns/iter (± 1998) 1.00
html/document/visitor/compare/visit_mut_span 365099 ns/iter (± 2153) 367891 ns/iter (± 1838) 0.99
html/document/visitor/compare/visit_mut_span_panic 370852 ns/iter (± 1539) 378343 ns/iter (± 2491) 0.98
html/document/visitor/compare/fold_span 401923 ns/iter (± 1878) 409718 ns/iter (± 2226) 0.98
html/document/visitor/compare/fold_span_panic 457738 ns/iter (± 1426) 465945 ns/iter (± 1786) 0.98
html/document_fragment/visitor/compare/clone 334144 ns/iter (± 1773) 336222 ns/iter (± 1710) 0.99
html/document_fragment/visitor/compare/visit_mut_span 367013 ns/iter (± 1406) 362833 ns/iter (± 2500) 1.01
html/document_fragment/visitor/compare/visit_mut_span_panic 370023 ns/iter (± 3071) 370407 ns/iter (± 1561) 1.00
html/document_fragment/visitor/compare/fold_span 399286 ns/iter (± 4586) 406743 ns/iter (± 1836) 0.98
html/document_fragment/visitor/compare/fold_span_panic 459892 ns/iter (± 1649) 460027 ns/iter (± 3150) 1.00
html/lexer/css_2021_spec 15550368 ns/iter (± 14915) 15554212 ns/iter (± 36572) 1.00
html/lexer/github_com_17_05_2022 6021430 ns/iter (± 4519) 6008585 ns/iter (± 9623) 1.00
html/lexer/stackoverflow_com_17_05_2022 5633894 ns/iter (± 12029) 5609862 ns/iter (± 4304) 1.00
html/parser/parser_document/css_2021_spec 26293747 ns/iter (± 192765) 26042056 ns/iter (± 146831) 1.01
html/parser/parser_document/github_com_17_05_2022 8770019 ns/iter (± 11304) 8800547 ns/iter (± 9337) 1.00
html/parser/parser_document/stackoverflow_com_17_05_2022 7714139 ns/iter (± 4384) 7757963 ns/iter (± 13928) 0.99
html/parser/parser_document_fragment/css_2021_spec 26797122 ns/iter (± 455780) 26173238 ns/iter (± 153488) 1.02
html/parser/parser_document_fragment/github_com_17_05_2022 8787531 ns/iter (± 16249) 8791442 ns/iter (± 10788) 1.00
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022 7742881 ns/iter (± 54971) 7724400 ns/iter (± 17119) 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.