Add regression test for event target on Control

* Check possible name collision of target element with EventTarget
This commit is contained in:
Edward Nash
2019-10-22 08:33:31 +02:00
parent e0cab3d3ba
commit ee653a8e0d

View File

@@ -54,3 +54,25 @@ describe('ol.control.Control\'s target', function() {
});
});
});
describe('ol.control.Control\'s event target', function() {
it('is the Control when the Control uses the default target', function() {
const ctrl = new Control({element: document.createElement('div')});
ctrl.on('test-event', function(e) {
expect(e.target).to.be(ctrl);
});
ctrl.dispatchEvent('test-event');
ctrl.dispose();
});
it('is the Control when the Control has a custom target', function() {
const ctrl = new Control({
element: document.createElement('div'),
target: document.createElement('div')
});
ctrl.on('test-event', function(e) {
expect(e.target).to.be(ctrl);
});
ctrl.dispatchEvent('test-event');
ctrl.dispose();
});
});