Skip to content

feat(minify): avoid removing the default value of the filter function#1121

Open
yisibl wants to merge 1 commit intoparcel-bundler:masterfrom
yisibl:add-avoid-filter
Open

feat(minify): avoid removing the default value of the filter function#1121
yisibl wants to merge 1 commit intoparcel-bundler:masterfrom
yisibl:add-avoid-filter

Conversation

@yisibl
Copy link
Contributor

@yisibl yisibl commented Jan 7, 2026

There are several inconsistencies in Chrome's implementation of defaults in older versions, which can cause filters to behave in opposite ways in older browsers. Perhaps other browsers have similar bugs with inconsistent defaults between old and new versions, I didn't continue searching.

In older versions of Chrome(49), -webkit-filter: brightness() also caused crashes.

Input

.foo {
  filter: brightness(1);
}

Output

.foo {
  -webkit-filter: brightness(); /* I'm also concerned that `-webkit-filter` does not support omitting the default values. */
  filter: brightness(); /* In older versions of Chrome, the calculated value is 0 */
}

I would recommend turning off arguments omitting of the functions in the filter by default, it's not worth sacrificing correctness for those few bytes.

Fixed: #251

There are several inconsistencies in Chrome's implementation of defaults in older versions, which can cause filters to behave in opposite ways in older browsers. Perhaps other browsers have similar bugs with inconsistent defaults between old and new versions, I didn't continue searching.

In older versions of Chrome(49), `-webkit-filter: brightness()` also caused crashes.

```css
.foo {
  filter: brightness(1);
}
```

```css
.foo {
  -webkit-filter: brightness(); /* I'm also concerned that `-webkit-filter` does not support omitting the default values. */
  filter: brightness(); /* In older versions of Chrome, the calculated value is 0 */
}
```

- https://bugs.chromium.org/p/chromium/issues/detail?id=964696#c13
- https://bugs.chromium.org/p/chromium/issues/detail?id=798683#c6

I would recommend turning off arguments omitting of the functions in the `filter` by default, it's not worth sacrificing correctness for those few bytes.

Fixed: parcel-bundler#251
@yisibl
Copy link
Contributor Author

yisibl commented Jan 7, 2026

@devongovett PTAL

@devongovett
Copy link
Member

Chrome 49 is almost 10 years old so I doubt anyone is targeting that anymore. But we could potentially check the targets and see if the minimum version is below that.

@yisibl
Copy link
Contributor Author

yisibl commented Jan 14, 2026

@devongovett Beyond the issue with -webkit prefix functions, the default value for brightness() also varies between older and newer versions of Chrome. Currently, this lacks MDN data.

.foo {
  -webkit-filter: brightness(); /* I'm also concerned that `-webkit-filter` does not support omitting the default values. */
  filter: brightness(); /* In older versions of Chrome, the calculated value is 0 */
}

When CSS authors explicitly write brightness(1), it's likely to circumvent browser bugs—and LightningCSS has brought that bug back. If this is meant to fix a live bug, it's incredibly frustrating.

So, I still stand by my view: we really shouldn't obsess over reducing byte counts. Maintaining CSS correctness is far more important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minifier: it is not safe to remove the default value of a function in filter

2 participants