Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Optionally leave shorthand instead parsing values #20

Closed
wants to merge 7 commits into from

Conversation

kopipejst
Copy link

Using shorthand notation in CSS is good practice so even if there are duplicates in most cases is better to leave them.

Example test.css:

.foo { 
    border: 1px solid #000; 
    color: #000; 
    padding: 10px 5px; 
}
.bar { 
    border: 1px solid #fff; 
    color: #000; 
    padding: 10px 2px; 
}

If we run csscss -v test.css -n 1 we'll get that there are 5 duplicates:

{.bar} AND {.foo} share 5 rules

  • border-style: solid
  • border-width: 1px
  • color: #000
  • padding-bottom: 10px
  • padding-top: 10px

However, in this case splitting border or padding shorthand notation is not good practice in CSS because file will be larger.
With --use-shorthand option shorthand will not be parsed so we'll get only one duplicate.

csscss -v test.css -n 1 --use-shorthand

{.bar} AND {.foo} share 1 rule

  • color: #000

@zmoazeni
Copy link
Owner

Thanks for submitting this @kopipejst! I'll take a look at this. I'm still on the fence whether shorthand matching should be the default or not but I'm thinking that regardless the default, it should be optional.

@tamvm
Copy link

tamvm commented Apr 11, 2013

@kopipejst +1

zmoazeni added a commit that referenced this pull request Apr 12, 2013
I'm fine with keeping shorthand matching the default, but I respect some
people don't like it.

refs: #20
zmoazeni added a commit that referenced this pull request Apr 12, 2013
@zmoazeni
Copy link
Owner

@kopipejst @tamvo I've just committed something similar but with the reverse logic. Default stays the same but you can now run csscss --no-match-shorthand ... to match on exact rules. Thanks for the pull request. I'm going to go ahead and close this unmerged.

@zmoazeni zmoazeni closed this Apr 12, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants