Skip to content

Commit

Permalink
Provide arguments for extend() mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta authored and miripiruni committed Nov 28, 2016
1 parent 863f26f commit 0c67103
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bemxjst/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ExtendMatch.prototype.wrapBody = function wrapBody(body) {
return function localAdaptor() {
var changes = {};

var obj = body.call(this);
var obj = body.call(this, this, this.ctx);
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++)
changes[keys[i]] = obj[keys[i]];
Expand Down
13 changes: 13 additions & 0 deletions test/modes-extend-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,17 @@ describe('Modes extend', function() {
{ block: 'b' },
'<div class="b" id="test">1</div>');
});

it('should pass BEMContext instance and json to extend body',
function() {
test(function() {
block('b')(
extend()(function(ctx, json) {
return { bar: json.foo + ' ' + ctx.constructor.name };
}),
content()(function() { return this.bar; })
);
}, { block: 'b', foo: 'This is' },
'<div class="b">This is ContextChild</div>');
});
});

0 comments on commit 0c67103

Please sign in to comment.