csso icon indicating copy to clipboard operation
csso copied to clipboard

No shorthand duplicates removed

Open mattpilott opened this issue 8 years ago • 4 comments

Hey,

Take a look at this test case: https://github.com/matt3224/remove-dupe-props-test

Whilst long hand duplicate properties get removed it seems the shorthand ones do not. Is there some config I need to add to achieve this or is it something that needs to be added?

I imagine this to be potentially difficult and this may be why it is the way it is. However if you were to do something like this:

.button {
    background: black;
}

.button {
    background: url('thing.png') no-repeat;
}

I would expect this:

.button {
    background: url('thing.png') no-repeat;
}

not this:

.button {
    background: black url('thing.png') no-repeat;
}

as thats what the browser will do. Thoughts welcome

mattpilott avatar May 17 '17 17:05 mattpilott

Issue is about background property only, see explanation in related issue (#330). It would be fixed in the future.

lahmatiy avatar May 17 '17 21:05 lahmatiy

I guess a priority system of properties would work good in these situations:

  1. if priority is equal, csso will render both properties untouched.
  2. if priority of case A have higher priority over case B, the csso will render case A.
  3. if priority of case B have higher priority over case A, the ccso will render case B.

I proposed this in Sass, maybe should work in CSSO: https://github.com/sass/sass/issues/2464

lucas-viewup avatar Jan 31 '18 18:01 lucas-viewup

The is not about property priority. CSSO doesn't merge background property values or override them due of the complexity of that property (various browser support, complex merge model, many edge cases). It will be fixed when CSSTree (a backend for processing CSS) provides necessary API for such kind of complex transformations.

Btw, I looked at the sample code and noticed that the current output is:

.button{background:#000;background:url(thing.png) no-repeat}

lahmatiy avatar Jan 31 '18 23:01 lahmatiy

@lahmatiy, It's not about merge background property, is like how git merge does, you want case A, case B or you want both.

lucas-viewup avatar Feb 05 '18 18:02 lucas-viewup