Skip to content

Commit

Permalink
runtime: do not propagate default mods
Browse files Browse the repository at this point in the history
Fix: #80
  • Loading branch information
indutny committed Aug 3, 2015
1 parent 6b9de40 commit 3c7f239
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"bem-xjst": "git+ssh://github.com/bem/bem-xjst.git#fccd9d4",
"bem-xjst": "git+ssh://github.com/bem/bem-xjst.git#6b9de40",
"benchmark": "^1.0.0",
"browserify": "^11.0.0",
"microtime": "^1.4.2",
Expand Down
4 changes: 0 additions & 4 deletions lib/bemhtml/runtime/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ function Context(bemhtml) {
this.mods = {};
this.elemMods = {};

// Original objects
this._mods = this.mods;
this._elemMods = this.elemMods;

this.position = 0;
this._listLength = 0;
this._notNewList = false;
Expand Down
4 changes: 2 additions & 2 deletions lib/bemhtml/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ BEMHTML.prototype.runOne = function runOne(json) {
if (json.mods)
context.mods = json.mods;
else
context.mods = context._mods;
context.mods = {};
} else {
if (!json.elem)
context.block = '';
Expand All @@ -314,7 +314,7 @@ BEMHTML.prototype.runOne = function runOne(json) {
if (json.elemMods)
context.elemMods = json.elemMods;
else
context.elemMods = context._elemMods;
context.elemMods = {};

var block = context.block || '';
var elem = context.elem;
Expand Down
13 changes: 13 additions & 0 deletions test/runtime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ describe('BEMHTML compiler/Runtime', function() {
}
}, '<div class="b1 b1_a_b"><div class="b2">yes</div></div>');
});

it('should lazily override mods without propagating them', function() {
test(function() {
block('b1').def()(function() {
return applyNext({ 'mods.a': 'yes' });
});
}, {
block: 'b1',
content: {
block: 'b2'
}
}, '<div class="b1 b1_a_yes"><div class="b2"></div></div>');
});
});

describe('elemMods', function() {
Expand Down

0 comments on commit 3c7f239

Please sign in to comment.