Skip to content

Commit 1903e8f

Browse files
committed
fix underflow
1 parent e48d547 commit 1903e8f

File tree

2 files changed

+25
-11
lines changed
  • crates/swc_ecma_minifier
    • src/compress/optimize
    • tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23

2 files changed

+25
-11
lines changed

crates/swc_ecma_minifier/src/compress/optimize/iife.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,11 @@ impl Optimizer<'_> {
11521152
}
11531153

11541154
if decl.count
1155-
+ (params.len()
1156-
- args
1157-
.iter()
1155+
+ (params.len().saturating_sub(
1156+
args.iter()
11581157
.filter(|a| a.expr.is_ident() || a.expr.is_lit())
1159-
.count())
1160-
* 2
1158+
.count(),
1159+
)) * 2
11611160
> 4
11621161
{
11631162
return None;

crates/swc_ecma_minifier/tests/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/output.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10078,13 +10078,28 @@
1007810078
*/ _proto.setValues = function(values) {
1007910079
var _this4 = this;
1008010080
each(selectConfigs, function(config, key) {
10081-
var el = _this4.$(config.selector), value = values[key], parser = config.parser;
10082-
if (value) {
10083-
for(var i = 0; i < el.options.length; i++)if (parseOptionValue(el.options[i].value, parser) === value) {
10084-
el.selectedIndex = i;
10085-
break;
10081+
!/**
10082+
* Sets the selected <option> element within a <select> element based on a
10083+
* given value.
10084+
*
10085+
* @param {Element} el
10086+
* The element to look in.
10087+
*
10088+
* @param {string} value
10089+
* the property to look on.
10090+
*
10091+
* @param {Function} [parser]
10092+
* Optional function to adjust the value before comparing.
10093+
*
10094+
* @private
10095+
*/ function(el, value, parser) {
10096+
if (value) {
10097+
for(var i = 0; i < el.options.length; i++)if (parseOptionValue(el.options[i].value, parser) === value) {
10098+
el.selectedIndex = i;
10099+
break;
10100+
}
1008610101
}
10087-
}
10102+
}(_this4.$(config.selector), values[key], config.parser);
1008810103
});
1008910104
}, /**
1009010105
* Sets all `<select>` elements to their default values.

0 commit comments

Comments
 (0)