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

Report a redundant body selector #9

Closed
macbre opened this issue Dec 20, 2013 · 3 comments · Fixed by #30
Closed

Report a redundant body selector #9

macbre opened this issue Dec 20, 2013 · 3 comments · Fixed by #30
Assignees
Milestone

Comments

@macbre
Copy link
Owner

macbre commented Dec 20, 2013

https://developers.google.com/speed/docs/best-practices/rendering:

Avoid using descendant selectors, especially those that specify redundant ancestors.
For example, the rule body ul li a {...} specifies a redundant body selector, since all elements are descendants of the body tag.

@ghost ghost assigned macbre Dec 20, 2013
@macbre
Copy link
Owner Author

macbre commented Dec 26, 2013

.module body > h2 { } /* match */
body ul li a  { } /* match */
body > h1 { } /* don't match */
html > body #foo .bar  /* don't match */

@kangax
Copy link

kangax commented Aug 5, 2014

There's a case that I think might be an exception to this "rule":

This is an excerpt from our sass file:

html.modal-popup-mode
  overflow: hidden  

  body
    overflow: hidden

which translates to

html.modal-popup-mode { ... }
html.modal-popup-mode body { .. }

"html" prefix aside (it's mostly for clarity), the nested body seems like a valid use case. We need to target it only when containing html element has certain class ("modal-popup-mode").

What do you think?

@macbre
Copy link
Owner Author

macbre commented Aug 5, 2014

@kangax, makes sense (but only if body is the last part of the selector).

Can you create a separate issue for this one? Thx!

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

Successfully merging a pull request may close this issue.

2 participants