Sub-issue of #1190252: [573] Use csslint as a weapon to beat the crappy CSS out of Drupal core

Inline with the CSS cleanup efforts of the HTML5 initiative, using CSSLint at http://csslint.net provides a quick way to code-sniff our css and tweak styles.

  1. Copy and paste the the stylesheet(s) below into the css lint tool at http://csslint.net and test.
  2. Fix any warnings or errors the tool finds.
  3. Patch Drupal 8 locally and make sure the css changes have not broken anything visually.
  4. Create patch and upload for the testbot.

Files: modules/taxonomy/taxonomy.css

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RobLoach’s picture

From https://gist.github.com/3006391

csslint: There are 3 problems in core/modules/taxonomy/taxonomy.css.

taxonomy.css
1: warning at line 2, col 1
Element (tr.taxonomy-term-preview) is overqualified, just use .taxonomy-term-preview without element name.
tr.taxonomy-term-preview {

taxonomy.css
2: warning at line 5, col 1
Element (tr.taxonomy-term-divider-top) is overqualified, just use .taxonomy-term-divider-top without element name.
tr.taxonomy-term-divider-top {

taxonomy.css
3: warning at line 8, col 1
Element (tr.taxonomy-term-divider-bottom) is overqualified, just use .taxonomy-term-divider-bottom without element name.
tr.taxonomy-term-divider-bottom {

Manuel Garcia’s picture

Status: Active » Needs review
FileSize
523 bytes

Here's a patch blindly implementing csslint suggested changes.

RobLoach’s picture

Status: Needs review » Reviewed & tested by the community

rob@Computron /var/www/drupal/8 $ node ../../csslint/release/npm/cli.js core/modules/taxonomy

csslint: No errors in core/modules/taxonomy/taxonomy.css.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

I really need someone who actually knows what's going on here to review the patch and confirm the changes here are good, and why. I don't mind committing a lot of these, but I want to understand what's happening, and everything here seems like it's just running it through a tool and saying "ok."

RobLoach’s picture

Status: Needs review » Reviewed & tested by the community

CSSLint is a tool to test and clean up your CSS. You can read about what it helps with over in the Rules. Parsing the CSS with this will help improve browser render performance, and help clean up issues that would otherwise be missed.

Essentially what we're doing here is:

  1. Clean up the CSS with CSSLint (add classes if needed)
  2. Confirm in the browser that the user interface is not affected with the change
  3. Run CSSLint again to confirm the CSS is now clean
  4. Upload the patch
  5. Test the patch
  6. RTBC said patch
  7. Dance
webchick’s picture

Yes, I understand the mechanics of all that. :P My question is, What are these specific CSS changes doing, and why is it good?

RobLoach’s picture

This particular issue cleans up overqualified elements.

droplet’s picture

Actually, it is duplicated (a part of) HTML5 cleanup. Compare to HTML5 CLEAN UP, it provided a standard tool to check the problem. I do suggest to close all duplicated issues: http://drupal.org/node/1190252#comment-6171090.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks; so according to the referenced link this is a small performance improvement by having a less-specific class selector, because it doesn't need to find the element first, then find the specific class.

I'm not sure what #8 means. But this seems simple enough.

Committed and pushed to 8.x. Thanks!

Manuel Garcia’s picture

Avoiding overqualified elements is only being suggested in order to reduce filesize, afaik. I don't think we should just implement every case where csslint is suggesting it.

At least in this case, I don't see anyone re-using the same classes on other html elements so I think we can safely asume it's ok to not specify the element in the css selector.

We could however run into trouble if the class names are more generic and could be perhaps used elsewhere by people on their own sites. In these cases we should keep the "overqualified elements" selectors. Of course, how to determain which is which is a different story, I suggest we use common sense and a bit of hope =)

Automatically closed -- issue fixed for 2 weeks with no activity.