-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pixel (px) height getting converted to points (pt) #654
Comments
* Updated minifyCSS compatibility to _not_ convert to points. clean-css/clean-css#654 * Added unminified dump of css for debugging to build directory Product Widget * Changed word-break:break-all to word-wrap:brake-word for better text handling
Do you experience any layout issues because of this change? According to MDN 4px is always 3pt: see https://developer.mozilla.org/en-US/docs/Web/CSS/length under "CSS units and dots-per-inch". |
Agree with kfitzgerald. Seems more like a bug. Maybe, this feature by default should be turned off, but turned on in the options. It is also worth to do with pc
|
however, it works in IE8, IE9, Windows Phone 8 IE10, Microsoft Edge, and in normal browsers. |
It should be compatible with IE7+ and all other engines so unless there are any specific issues I am going to leave it on by default.
|
How can I disable this? |
Like compatibility with JavaScript that reads the current style of a node? Project-specific JavaScript should be allowed to work off of the very sensible expectation that particular sizes written in the uncompressed CSS files as pixels will remain as pixels and will thus be read as pixels. Flipping units like this can lead to very, very hard to catch layout bugs... |
@rjgotten this is exactly what I am dealing with right now. It broke everything. This is the most useless optimization that is nowhere documented (or shown how to disable it). Com'on, because of these few chars recalculate units? Turn that off by default, this conversion is will also be hated by many other developers, I guarantee it! There are websites that rely on a given unit, print versions etc. |
@jakubpawlowicz Thanks for the prompt reply! While the pixel-physical unit relationship MDN notes from the W3 CSS2 spec is valid, the CSS2 specification (http://www.w3.org/TR/CSS2/syndata.html#length-units) goes into more detail, specifically:
So to summarize, I don't mind if my units get converted to a more optimal format. However, I do mind if my specified units get converted from physical units to non-physical units (pixel), or vise versa. Since browsers / screen-media might not be the only avenue that could benefit from clean-css (print-media, PrinceXML etc) I would suggest avoiding blurring the lines between physical units and pixels. Thanks again! |
while you can be fixed so
|
@westyby does this disable/remove all the listed units? If yes, that's no solution, I use multiple units in my css. I switched my package to get the job done. Good luck with the owner here! |
uikid, No, it disables automatic translation units during the processing plugin. All these units you can still use CSS, they will remain
after
|
@kfitzgerald thanks for digging into the w3c spec. I agree we should not blur the lines and provide a nice set of options to control this behavior - I can think of deriving optimization rules from an output medium (screen, print, etc) which could be the first step of setting up css minification. So far clean-css targets mostly browsers but you can still customize quite for other use cases. @westyby @uikid you can disable Please bear in mind that any optimizations, be it lossy image encoding, JavaScript (to lesser extent) and CSS can break your site if you do something unusual. Re argument that getting property values from JavaScript would break sites is true to any optimization any CSS optimizer does. However I would be interested in a way of telling people what settings they should use for their particular use case. Any ideas? |
Nonsense. Merging long-hand properties into a short-hand property or removing duplicated properties are examples of optimizations that are safe. Those type of changes will not be reflected in In contrast, changing the unit of a property value is a prime example of an operation that is unsafe because those changes do leak out through You should really have a look at what UglifyJS does: only enable a set of strictly safe transformations by default and make everything else opt-in only. That way users can reasonally safely upgrade the package to resolve bugs, get better performance or better compression results, without requiring that they tread glass and keep their fingers crossed hoping that no new unsafe transformations were added that would make an existing project fall apart. This is seriously the sixth time in four months time that I'm seeing this kind of thing happen. In my book that makes it a big, priority one, problem to solve. |
Please correct me if I'm wrong but And it all depends on a context. Are clean-css transformations safe for IE7+ context? Nope, you have an option for that. Can you merge in a longhand Similarly if you rely on JavaScript I am sorry to hear clean-css broke your site. I do my best to keep everything well tested but it's not always possible to cover 100% of test cases. |
Please record my vote for making this optimization optional i.e. not enabled by default. Such experiments should be backed up by a set of wide tests in many browsers, not by “there’s an article on MDN stating that it’s safe” reply days after the release. |
As you wish. DOM2 mentions that:
Where computed values are specified by CSS2 as:
The Browsers that convert absolute units to
In other words; depending on what property you are reading, absolute units may be converted due to maintaining backwards compatibility or may not be converted when used within newer CSS constructs. Thus you cannot make the case that they will be converted in general, because they won't. Also, browser vendors are in principal free to, at one point, drop the legacy CSS 2.0 behavior completely and fully adopt the correct CSS 2.1 behavior for all CSS properties.
One of the core optimizations of a minifier is to perform safe name substitution. If you use reflection/inflection flavored constructs such as serializing a function body to a string, then yes: that will break. But anyone using a minifier can reasonably expect that kind of thing to break. Swapping out units on a CSS value to crunch out ~200 additional bytes is not a core optimization of a CSS minifier. From this thread alone it has already been proven destructive in practice, which means you shouldn't do it _by default_. (Note that? It should still be an option for those people that know their code can handle it. Principle of least surprise at work there...) |
I'm also against enabling such option by default.
|
I'm also against enabling such option by default, please correct this asap... |
+1 for not having this option enabled by default. |
+1 |
+1 I was like wtf happened to my css^^ |
+1 |
+1 Seems a little much.. Please disable this by default. |
+1 for disabling this by default |
1 similar comment
+1 for disabling this by default |
+1 for disabling this by default. For one thing, it screws up HTML emails. |
@rjgotten that's an argument against @kizu it was tested in IE7 up to 11 and Edge, old and new Firefox, Chrome, Safari, and Opera. Re 2 & 4 the same applies to other transformations, re 3 it's not implemented anyway @ruandre does it happen in browsers or in email clients? I am still looking forward to a reproducible rendering issue as per https://github.com/jakubpawlowicz/clean-css/blob/master/CONTRIBUTING.md - if there's such I will seriously consider reverting the change. |
Hi @jakubpawlowicz ! I'm not sure that reverting the change is the best option. I feel like adjusting the existing functionality to keep apples-to-apples (pixels) and oranges-to-oranges (physical units) would be a better alternative, satisfying the vast majority of cases. Thanks again, |
Thanks @kfitzgerald - yeah, that's what I meant. |
Can you provide examples of those transformations?
Right now clean-css would break such polyfilled code. Other transformations don't have this issue, as authors would expect users to use both Regarding dev tools — which transformations make it harder to tweak values at the same level as converting units? |
+1 for disabling this by default. |
+1 for disabling this by default |
+1 for disabling this by default. |
As far as I understand, it's not even possible to disable the optimization cleanly; you have to disable parsing/using the target unit of the conversion ( |
+1 for disabling this by default. |
2 similar comments
+1 for disabling this by default. |
+1 for disabling this by default. |
Due to a popular request length unit optimizations are being disabled. This change (API-wise) is backward-compatible, so there is no need for a new minor release, however it introduces a `properties.shorterLengthUnits` switch if someone would like to use the optimizations again.
It's released as 3.4.2 where length unit optimizations are disabled by default. Those can be brought back using Thanks everyone for all the comments and +1s. It made me realize it wasn't the best idea to turn it on by default. |
Thanks @jakubpawlowicz ! Much appreciated. |
There are a lot of radical compression should be disabled by default. |
@yisibl Will deal with it in the next major release. |
+1 for disabling it by default |
@rene-poulsen it's off in 3.4.2+. |
@jsw0528 fix. |
Cooooooooooooooooooooooooool~ |
+1 thanks for disabling it, it gave me headaches to understand why a very specific case got broken in Safari due to the px to picas conversion. |
@jakubpawlowicz +1 for conceding to peer pressure gracefully (i.e. listening to user demands), thank you, much appreciated. |
Greetings!
I just updated the dependencies for one of my projects and ran into this issue. I've got a pixel height in a pseudo-selector and it's getting converted into points.
Here's a snippet of the affected css prior to minification:
And here's the snippet after:
My expected result is:
IMHO, pixels and points are two completely different animals, and should not be interchangeable. This is very much undesirable functionality.
After some digging, my current workaround is to kill the pt unit and set the compatibility config:
But I don't feel like I should have to do this. Seems more like a bug.
For reference, on my other machine where I did not experience this issue, my dependency graph is:
And my new machine where this issue is present, the dependency graph looks like this:
Thanks!
-Kevin
The text was updated successfully, but these errors were encountered: