Git Product home page Git Product logo

Comments (6)

1999 avatar 1999 commented on September 27, 2024

cc @megatolya

from bh.

qfox avatar qfox commented on September 27, 2024

Compare this:

.button_red { color: red }
.button { color: green }

with this:

bh.match('button_red', function(ctx) { ctx.content('red'); });
bh.match('button', function(ctx) { ctx.content('green'); });

Button should be green. Okay?

from bh.

1999 avatar 1999 commented on September 27, 2024

@zxqfox let's assume that you have this bemjson: {block: "button", mods: {red: true}}. Then it shouldn't. Templates are applied from the most specific to the least one. In your case button_red template will be applied first and it will set content ("red"). Then button template should be applied, but content has already been set, so its content won't change.

from bh.

qfox avatar qfox commented on September 27, 2024

@1999 Actually. It should even if you have {block: "button", mods: {red: true}}.

.button_red, as well as bh.match('button_red', should go last to have the most weight.

.button { color: green }
.button_red { color: red }

+

bh.match('button', function(ctx) { ctx.content('green'); });
bh.match('button_red', function(ctx) { ctx.content('red'); });

=
Really red button modifier.

from bh.

1999 avatar 1999 commented on September 27, 2024

@zxqfox I'm not sure about this. Anyway @mishanga will help us.

from bh.

mishanga avatar mishanga commented on September 27, 2024

Я склоняюсь к тому, что это нормальное поведение: все подходящие шаблоны применяются в том порядке, в каком задекларированы (точнее, в обратном). Это аналогично поведению CSS. На мой взгляд, это понятное и ожидаемое поведение (если опять же проводить аналогию с CSS).
Кроме того, BEMHTML работает так же. Срабатывает тот шаблон, который задекларирован последним, независимо от наличия подпредиката про модификатор.
2015-04-22_1618

Won't fix.

from bh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.