Skip to content

Commit

Permalink
Merge pull request #1368 from /issues/1362@v4
Browse files Browse the repository at this point in the history
i-bem-dom__event: Ensure that we have ability to bind events from class to block with specified modifier
  • Loading branch information
veged committed Jun 1, 2016
2 parents 6178d12 + 5d12512 commit 3e47f5c
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var undef,
expect = chai.expect;

describe('DOM events', function() {
var Block1, Block2, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7,
var Block1, Block2, Block3, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7,
wrapSpy = function(spy) {
return function(e) {
// NOTE: we need to pass bemTarget and data explicitly, as `e` is being
Expand Down Expand Up @@ -649,9 +649,21 @@ describe('DOM events', function() {
}
});

Block3 = bemDom
.declBlock('block3')
.declMod({ modName : 'm1', modVal : 'v1' }, {}, {
onInit : function() {
this._domEvents({ modName : 'm1', modVal : 'v1' }).on('click', spy6);
}
});

block1 = initDom({
block : 'block1',
mix : { block : 'block2', js : true }
mix : { block : 'block2', js : true },
content : [
{ block : 'block3', js : true },
{ block : 'block3', mods : { m1 : 'v1' }, js : true }
]
}).bem(Block1);
});

Expand Down Expand Up @@ -705,6 +717,16 @@ describe('DOM events', function() {
block1.domElem.trigger('click');
spy4.should.not.have.been.called;
});

it('should properly bind to self with modifier', function() {
var blocks = block1.findChildBlocks(Block3);

blocks.get(0).domElem.trigger('click');
spy6.should.not.have.been.called;

blocks.get(1).domElem.trigger('click');
spy6.should.have.been.called;
});
});

describe('block elems events', function() {
Expand Down

0 comments on commit 3e47f5c

Please sign in to comment.