diff --git a/packages/metal-dom/src/dom.js b/packages/metal-dom/src/dom.js index 73e084fc..855e4a93 100644 --- a/packages/metal-dom/src/dom.js +++ b/packages/metal-dom/src/dom.js @@ -730,6 +730,13 @@ class dom { * @protected */ static triggerMatchedListeners_(container, element, event, defaultFns) { + if (event.type === 'click' && event.button === 2) { + // Firefox triggers "click" events on the document for right clicks. This + // causes our delegate logic to trigger it for regular elements too, which + // shouldn't happen. Ignoring them here. + return; + } + var data = domData.get(element); var listeners = data.listeners[event.type]; var ret = dom.triggerListeners_(listeners, event, element, defaultFns); diff --git a/packages/metal-dom/test/dom.js b/packages/metal-dom/test/dom.js index 7c86557d..672a0ede 100644 --- a/packages/metal-dom/test/dom.js +++ b/packages/metal-dom/test/dom.js @@ -759,6 +759,20 @@ describe('dom', function() { assert.strictEqual(0, listener2.callCount); }); + it('should not trigger delegate "click" listener for right clicks', function() { + var element = document.createElement('div'); + dom.enterDocument(element); + var child = document.createElement('div'); + dom.append(element, child); + + var listener = sinon.stub(); + dom.delegate(element, 'click', child, listener); + dom.triggerEvent(child, 'click', { + button: 2 + }); + assert.strictEqual(0, listener.callCount); + }); + it('should run default listeners last', function() { var element = document.createElement('div'); dom.enterDocument(element);