lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Option to not add units of measure

Open stoyan opened this issue 1 year ago • 1 comments

Currently

a{width:1}

becomes

a{width:1px}

which breaks my UI by turning invalid CSS into a valid one.

(Of course the right thing to do is to fix my origin code to not contain invalid CSS. But in a large project that may take a while and hurt the adoption of LightningCSS.)

I think in this case the correct behavior would be to drop the property completely as its value is incorrect.

stoyan avatar Feb 26 '24 20:02 stoyan

Lightning CSS is a bit lenient here to support quirks mode, where unitless lengths are supported in some properties: https://drafts.csswg.org/css-values-4/#deprecated-quirky-length. Perhaps there should be an option to make this more strict, as mentioned in the code here: https://github.com/parcel-bundler/lightningcss/blob/445def9a77f89aa612fecb2f776261fc2c9d8f66/src/values/length.rs#L145-L148

devongovett avatar May 14 '24 05:05 devongovett