question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

O0 is not equivalent to O1 all:off

See original GitHub issue

Environment

  • clean-css version - npm ls clean-css: 4.1.5
  • node.js version - node -v: 8.1.0
  • operating system: macOS 10.12.5

Configuration options

-O0

cleancss public/styles.css -o public/clean.css -O0

-O1 all:off

cleancss public/styles.css -o public/clean.css -O1 all:off

Input CSS

* {
  min-width: 0%;
}

Actual output CSS

-O0

*{min-width:0%}

-O1 all:off

*{min-width:0}

Note that the % unit has been removed.

Expected output CSS

*{min-width:0%}

Why does this matter? Because, due to flexbox bugs in IE11, min-width: 0 is interpreted as min-width: 0px, which is not evaluated the same way as min-width: 0% (even though they are, to the best of my knowledge, equivalent according to the spec). I have a repro where 0px causes a layout glitch in IE11, and 0% does not! You can use the IE11 web dev tools to change the unit back and forth between 0px and 0% and see things break and unbreak. Maddening, hey?

What’s doubly painful for me is… I can’t find which clean-css configuration option is causing the % unit to be stripped. I’d like to turn that config option off, but it doesn’t seem to be documented, and I haven’t be able to find it by doing a brief source dive. If I can’t turn this unit stripping off, I’m afraid I’ll be stuck using O0 to compile my projects, which basically defeats the purpose of using clean-css at all.

So, two things I’d love:

  1. I’d love -O1 all:off to be equivalent to -O0, or alternatively for the difference to be documented.
  2. I’d love to know why unit are being stripped when run with -O1 all:off, and what config option I can set to stop units from being stripped.

Cheers!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jakubpawlowiczcommented, Mar 30, 2022

This issue has been long overdue, but in clean-css 5.x 1) the level 1 optimizations are applied on a much more fine-grained level, see https://github.com/clean-css/clean-css/blob/master/lib/optimizer/configuration.js#L1172, and 2) zeroUnits compatibility flag is always respected, see https://github.com/clean-css/clean-css/blob/master/lib/optimizer/level-1/value-optimizers/zero.js#L36

One can run now this and they will be fine:

var CleanCSS = require('clean-css');
new CleanCSS({compatibility: {properties: {zeroUnits: false}}, level: {1: {all: false}}}).minify('*{min-width:0%}')

Hope it still helps someone.

0reactions
jakubpawlowiczcommented, Jul 13, 2017

Given there are restrictions when units are removed you are probably right!

Read more comments on GitHub >

github_iconTop Results From Across the Web

O1 Visa Category and Evidentiary Requirements
The O1 visa category is for aliens of extraordinary ability or ... An O petition must be filed not more than one year...
Read more >
Trying to Capture Invalid Ethernet Frames
Not all Ethernet NICs are Created Equal - Trying to Capture Invalid Ethernet Frames, Author: Rob VandenBrink.
Read more >
Form I-129, Petition for Nonimmigrant Worker - USCIS
If filing for an O-2 or P support classification, list dates of the beneficiary's prior work experience under the principal O-1 or P...
Read more >
Details of the policy definition structure - Azure - Microsoft Learn
Describes how policy definitions are used to establish conventions for Azure resources in your organization.
Read more >
desr 6055.09_afman91-201_afgm2022-01 - Air Force
(T-0) Do not display NFPA and OSHA placards concurrently ... (Added)(AF) Immediately provide personnel protection equivalent to PTR.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found