Skip to content
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

Remove unneeded #1

Open
jiewmeng opened this issue Jun 26, 2014 · 3 comments
Open

Remove unneeded #1

jiewmeng opened this issue Jun 26, 2014 · 3 comments

Comments

@jiewmeng
Copy link

Firstly, I'd like to commend you on creating this useful tool.

I did however notice some possible optimizations. For example, when I have multiple declarations of the same type, it should be possible to remove the previous declarations?

a { color: #ff0000; }
a { color: red; }
/* currently results in ... */
a{color:red;color:red}
/* ... but it should be ... */
a{color:red;}

Also, if multiple overriding declarations of the same type exists, only the last one need to stay?

a { color: red; color: blue; }
/* currently results in ... */
a{color:red;color:blue}
/* ... but it should be ... */
a{color:blue;}
@a5e
Copy link

a5e commented Jun 26, 2014

You forget that it is sometimes necessary to have multiple declarations for fallback purposes.

a {
  color: red; /* for IE8- which doesn't support rgba */
  color: rgba(255, 0, 0, 0.5); /* for others */
}

@thierryk
Copy link

Also, if multiple overriding declarations of the same type exists, only the last one need to stay?

It is not that simple. Consider this for example:

body {
  background-color: teal; /* for IE8- which doesn't support rgba */
  background-color: rgba(0, 128, 128, .3); /* for others */
  *background-color: teal; /* for IE6/7 - which drop both rules above */
  color: #333 !important;
  color: #fff; /* for IE 6 */
}

This is a test page for the above

@jiewmeng
Copy link
Author

jiewmeng commented Jul 3, 2014

Agreed. Perhaps one possibility is deal only with the "simpler" cases. If values result in the same outcome. eg. #fff vs #ffffff vs white then keep only the last. Perhaps that might work. May need to normalize them to a single format like 6 digit hex. Maybe only include rgba where alpha is 1. Just a suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants