-
Notifications
You must be signed in to change notification settings - Fork 66
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
Inconsistency in how bemto identifies a primary block/element class #72
Comments
Hmm, yes, that was intentional, but I can see how this can be a problem. Thanks for the report! The intention was in 1.0.0 to provide better support for mixing elements, so you could do +b.foo._mod1._mod2.bar._mod3._mod4 and get proper result: <div class="foo foo_mod1 foo_mod2 bar bar_mod3 bar_mod4">
</div> Before 1.0.0 it was impossible as every modifier went to only the first block. And now, as the class from the attribute is added in the end of the class chain, it becomes a modifier for the last block there. I can see how I could improve the current situation by adding a way to mark some of the blocks “primary”. The default behaviour would stay as it is now, but you would be able to do something like this: +b.Component_.otherclass(class='_modifier')
+e.Element or adding I'll see if I could introduce this feature today or tomorrow. |
I guess I don't really see the use case for the above... I always would assume it would come out like this: <div class="foo foo_mod1 foo_mod2 bar foo_mod3 foo_mod4">
</div> I'm not a fan of the proposed syntax, as I'd have to add the extra suffix, eg. It seems as though #70 is closer to what the behaviour _should _be on block elements, so that to achieve your example: <div class="foo foo_mod1 foo_mod2 bar bar_mod3 bar_mod4">
</div> You would actually use: +b.foo._mod1._mod2.bar__._mod3._mod4 That way I wouldn't want to introduce a special syntax to indicate the "primary" component, as it accommodates a small use case and could introduce confusion. |
That still leaves the problem of which element should inherit elements that appear in the What do you think? |
Hey @kizu,
I wanted to report this issue because I don't know if it's actually a bug or not.. maybe it's just something that needs documenting, or maybe you had a good reason to do this.
If I write:
It compiles as expected to:
But if I change it to:
It renders:
It appears that when you use the
class
attribute (as I sometimes do to dynamically insert extra modifier classes) instead of passing the modifiers directly into the selector, bemto will add the modifier class onto the last class in the selector, when, in previous versions and in most other cases, bemto will identify the first class after+b
or+e
as the primary class.The text was updated successfully, but these errors were encountered: