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

About nested components #2

Open
lolenko opened this issue Feb 9, 2015 · 4 comments
Open

About nested components #2

lolenko opened this issue Feb 9, 2015 · 4 comments

Comments

@lolenko
Copy link

lolenko commented Feb 9, 2015

Your structure does't work when we have nested components with same elements names.

.foo-1 {
  .bar {}
}

.foo-2 {
  .bar {}
}

.foo-1
  .bar
  .foo-2
    .bar

In this case selector .foo-1 .bar affects on "bar" element of "foo-2" component

In BEM it's fine

@emmgfx
Copy link

emmgfx commented Feb 9, 2015

.bar can be inside .foo-1 or .foo-2 and may have different properties. Is not the same element.

.foo-1
   .bar
.foo-2
   .bar

@rstacruz
Copy link
Owner

rstacruz commented Feb 9, 2015

Indeed that's true: https://github.com/rstacruz/rscss#bleeding-through-nested-components

You may need to use the child selector (> .bar) in those cases. (bonus: its more efficient than descendant selectors .foo-1 .bar!)

actually on that note, it might be a good idea to recommend > everywhere...

@lolenko
Copy link
Author

lolenko commented Feb 10, 2015

In advance we don't know about nested case, so components are't independent.

We are limited by element nesting level in HTML, if we write > everywhere. Components can't always be quite simple.

@ValdasK
Copy link

ValdasK commented Feb 10, 2015

Avoid rule nesting at all costs, that's where BEM shines.

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

4 participants