Skip to content

Commit 241a9c6

Browse files
committed
try safe-guard before dispathEvent() calls
1 parent 872d2c9 commit 241a9c6

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

test/jasmine/assets/modebar_button.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function selectButton(modeBar, name) {
1818

1919
button.click = function() {
2020
var ev = new window.MouseEvent('click');
21-
node.dispatchEvent(ev);
21+
if(node) node.dispatchEvent(ev);
2222
};
2323

2424
button.isActive = function() {

test/jasmine/assets/mouse_event.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = function(type, x, y, opts) {
4545
ev = new window.MouseEvent(type, fullOpts);
4646
}
4747

48-
el.dispatchEvent(ev);
48+
if(el) el.dispatchEvent(ev);
4949

5050
return el;
5151
};

test/jasmine/assets/touch_event.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ module.exports = function(type, x, y, opts) {
3636
fullOpts.shiftKey = opts.shiftKey;
3737
}
3838

39-
4039
ev = new window.TouchEvent(type, Lib.extendFlat({}, fullOpts, opts));
4140

42-
el.dispatchEvent(ev);
41+
if(el) el.dispatchEvent(ev);
4342

4443
return el;
4544
};

test/jasmine/tests/annotations_test.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,9 @@ describe('annotation effects', function() {
15471547

15481548
setTimeout(function() {
15491549
var input = d3.select('.plugin-editable.editable');
1550-
input.node().dispatchEvent(new KeyboardEvent('blur'));
1550+
if(input.node()) {
1551+
input.node().dispatchEvent(new KeyboardEvent('blur'));
1552+
}
15511553
}, DBLCLICKDELAY * 1.1);
15521554
});
15531555
}

0 commit comments

Comments
 (0)