Comments (6)
cc @megatolya
from bh.
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.
@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.
@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.
@zxqfox I'm not sure about this. Anyway @mishanga will help us.
from bh.
Я склоняюсь к тому, что это нормальное поведение: все подходящие шаблоны применяются в том порядке, в каком задекларированы (точнее, в обратном). Это аналогично поведению CSS. На мой взгляд, это понятное и ожидаемое поведение (если опять же проводить аналогию с CSS).
Кроме того, BEMHTML работает так же. Срабатывает тот шаблон, который задекларирован последним, независимо от наличия подпредиката про модификатор.
Won't fix.
from bh.
Related Issues (20)
- Readme: describe `bh.toHtml()`
- Need documentation on new global matcher feature
- jsElem
- jsAttr Defaults: `data-bem` name + `json` scheme HOT 7
- bh.require
- Documentation on escaping utils
- Proposal: ctx.if() HOT 5
- Add more examples for boolean attributes to README
- add tProxy shortcut
- Bug with ctx.js() HOT 6
- BH doesn't extend client 'js' param when it equal true HOT 3
- How to off escaping for .content() HOT 4
- Демо не работает в Firefox
- tParam rewrites value from previous level HOT 2
- How to achieve a bemhtml replace() like behaviour? HOT 7
- Option to drop trailing slashes for short tags
- Remove eval from runtime HOT 2
- What about escaping specific BEMJSON field, e.g. 'contentSafe'? HOT 14
- Матчинг на элемент по модификатору блока HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bh.