diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index 72dcba4ff..5be06461a 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -94,7 +94,7 @@ export function behaviorHover(context) { function pointerover() { // ignore mouse hovers with buttons pressed unless dragging - if (!context.mode().id.includes('drag') && + if (context.mode().id.indexOf('drag') === -1 && (!d3_event.pointerType || d3_event.pointerType === 'mouse') && d3_event.buttons) return; diff --git a/test/spec/behavior/hover.js b/test/spec/behavior/hover.js index 4dbc5ac9a..75f506d27 100644 --- a/test/spec/behavior/hover.js +++ b/test/spec/behavior/hover.js @@ -30,7 +30,7 @@ describe('iD.behaviorHover', function() { }); }); - describe('mouseover', function () { + describe('mouseover and mouseout', function () { it('adds the .hover class to all elements to which the same datum is bound', function () { var a = iD.osmNode({id: 'a'}); var b = iD.osmNode({id: 'b'}); @@ -45,6 +45,9 @@ describe('iD.behaviorHover', function() { expect(_container.selectAll('.a.hover').nodes()).to.have.length(2); expect(_container.selectAll('.b.hover').nodes()).to.have.length(0); + + iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseout'); + expect(_container.selectAll('.hover').nodes()).to.have.length(0); }); it('adds the .hover class to all members of a relation', function() { @@ -61,16 +64,8 @@ describe('iD.behaviorHover', function() { expect(_container.selectAll('.a.hover').nodes()).to.have.length(1); expect(_container.selectAll('.b.hover').nodes()).to.have.length(1); - }); - }); - - describe('mouseout', function () { - it('removes the .hover class from all elements', function () { - _container.append('span').attr('class', 'hover'); - - _container.call(iD.behaviorHover(_context)); - iD.utilTriggerEvent(_container.selectAll('.hover'), 'mouseout'); + iD.utilTriggerEvent(_container.selectAll('.a'), 'mouseout'); expect(_container.selectAll('.hover').nodes()).to.have.length(0); }); });