Skip to content

Commit 41960c3

Browse files
committed
fixup! Fix for window as domNode
1 parent 24045e2 commit 41960c3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

common.blocks/i-bem-dom/__events/_type/i-bem-dom__events_type_dom.spec.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var undef,
77
expect = chai.expect;
88

99
describe('DOM events', function() {
10-
var Block1, Block2, Block3, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7, spy8,
10+
var Block1, Block2, Block3, block1, spy1, spy2, spy3, spy4, spy5, spy6, spy7, spy8, spy9,
1111
wrapSpy = function(spy) {
1212
return function(e) {
1313
// NOTE: we need to pass bemTarget and data explicitly, as `e` is being
@@ -26,6 +26,7 @@ describe('DOM events', function() {
2626
spy6 = sinon.spy();
2727
spy7 = sinon.spy();
2828
spy8 = sinon.spy();
29+
spy9 = sinon.spy();
2930
});
3031

3132
afterEach(function() {
@@ -1038,6 +1039,24 @@ describe('DOM events', function() {
10381039
});
10391040
});
10401041
});
1042+
1043+
describe('window events', function() {
1044+
beforeEach(function() {
1045+
Block1 = bemDom.declBlock('block1', {}, {
1046+
onInit : function() {
1047+
this._domEvents(window).on('resize', spy9);
1048+
}
1049+
});
1050+
1051+
block1 = initBemEntity({ block : 'block1' }, Block1);
1052+
});
1053+
1054+
it('should properly bind handlers', function() {
1055+
windowDispatchEvent('resize');
1056+
1057+
spy9.should.have.been.called;
1058+
});
1059+
});
10411060
});
10421061
});
10431062

common.blocks/i-bem-dom/__events/i-bem-dom__events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ var undef,
346346

347347
if(params.bindClassName) {
348348
do {
349-
if(domNode.classList && domNode.classList.contains(params.bindClassName)) {
349+
if(domNode.classList.contains(params.bindClassName)) {
350350
targetDomNode = domNode;
351351
break;
352352
}
@@ -358,7 +358,7 @@ var undef,
358358
} else {
359359
do {
360360
if(!targetDomNode) {
361-
if(domNode.classList.contains(params.bindClassName)) {
361+
if(domNode.classList && domNode.classList.contains(params.bindClassName)) {
362362
targetDomNode = domNode;
363363
} else continue;
364364
}

0 commit comments

Comments
 (0)