Skip to content

Commit

Permalink
fixup! Fix for window as domNode
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Jul 24, 2018
1 parent 24045e2 commit 41960c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 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, Block3, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7, spy8,
var Block1, Block2, Block3, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7, spy8, spy9,
wrapSpy = function(spy) {
return function(e) {
// NOTE: we need to pass bemTarget and data explicitly, as `e` is being
Expand All @@ -26,6 +26,7 @@ describe('DOM events', function() {
spy6 = sinon.spy();
spy7 = sinon.spy();
spy8 = sinon.spy();
spy9 = sinon.spy();
});

afterEach(function() {
Expand Down Expand Up @@ -1038,6 +1039,24 @@ describe('DOM events', function() {
});
});
});

describe('window events', function() {
beforeEach(function() {
Block1 = bemDom.declBlock('block1', {}, {
onInit : function() {
this._domEvents(window).on('resize', spy9);
}
});

block1 = initBemEntity({ block : 'block1' }, Block1);
});

it('should properly bind handlers', function() {
windowDispatchEvent('resize');

spy9.should.have.been.called;
});
});
});
});

Expand Down
4 changes: 2 additions & 2 deletions common.blocks/i-bem-dom/__events/i-bem-dom__events.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ var undef,

if(params.bindClassName) {
do {
if(domNode.classList && domNode.classList.contains(params.bindClassName)) {
if(domNode.classList.contains(params.bindClassName)) {
targetDomNode = domNode;
break;
}
Expand All @@ -358,7 +358,7 @@ var undef,
} else {
do {
if(!targetDomNode) {
if(domNode.classList.contains(params.bindClassName)) {
if(domNode.classList && domNode.classList.contains(params.bindClassName)) {
targetDomNode = domNode;
} else continue;
}
Expand Down

0 comments on commit 41960c3

Please sign in to comment.