trullock / NUglify

NUglify is a HTML, JavaScript and CSS minification Library for .NET (fork of AjaxMin + new features)
Other
396 stars 79 forks source link

Dimensions should not be stripped from custom CSS properties #309

Closed AndyMcKenna closed 2 years ago

AndyMcKenna commented 2 years ago

Using v1.19.0

Describe the bug We've got a CSS rule of height: calc(758px - var(--tpi-space)); and --tpi-space: 0px;. The px gets stripped off and breaks the calc. I saw #74 but the fact that we're using var() hides the calc check that you have. I think as a workaround I'm going to make these values 1px but long term it would be great to whitelist properties that start with -- similar to the existing check on flex and/or have a configuration option that disables dimension stripping altogether.

To Reproduce I modified the CSS/Values expected/input files to test

Minified output or stack trace body{width:12em;height:42ex;text-indent:4.666ch;font-size:3rem;border-bottom-width:.1vh;border-left-width:.1vw;border-right-width:.2vmin;border-top-width:.5vmax;--custom-property:0}

Excepted output code body{width:12em;height:42ex;text-indent:4.666ch;font-size:3rem;border-bottom-width:.1vh;border-left-width:.1vw;border-right-width:.2vmin;border-top-width:.5vmax;--custom-property:0px}

trullock commented 2 years ago

Can you provide the input that generated that output (vs its expected)

ta

AndyMcKenna commented 2 years ago

I can't believe I forgot to include that.

body { width: 12em; height: 42ex; text-indent: 4.666ch; font-size: 3rem; border-bottom-width: 0.1vh; border-left-width: 0.1vw; border-right-width: 0.2vmin; border-top-width: 0.5vmax; --custom-property: 0px; }

trullock commented 2 years ago

so I understand your example inputs/outputs and will take a look.

Is this separate to calc(var(--whatever))? Are there two issues?

AndyMcKenna commented 2 years ago

I think it's just the one issue. calc(var(--whatever)) would be fine if it resolved to 0px because that's what happens when we don't minimize.

trullock commented 2 years ago

Fixed in 1.19.1