diff --git a/compat/test/browser/events.test.js b/compat/test/browser/events.test.js index b7a9d1d7fe..d59dbef8ed 100644 --- a/compat/test/browser/events.test.js +++ b/compat/test/browser/events.test.js @@ -2,7 +2,8 @@ import { render } from 'preact'; import { setupScratch, teardown, - createEvent + createEvent, + supportsPassiveEvents } from '../../../test/_util/helpers'; import React, { createElement } from 'preact/compat'; @@ -309,4 +310,24 @@ describe('preact/compat events', () => { scratch.firstChild.dispatchEvent(createEvent('focusout')); expect(spy).to.be.calledOnce; }); + + if (supportsPassiveEvents()) { + it('should use capturing for event props ending with *Capture', () => { + let click = sinon.spy(); + + render( +
+ +
, + scratch + ); + + expect(proto.addEventListener).to.have.been.calledOnce; + expect(proto.addEventListener).to.have.been.calledWithExactly( + 'touchmove', + sinon.match.func, + true + ); + }); + } }); diff --git a/src/diff/props.js b/src/diff/props.js index 6421330bd0..3ec7e91141 100644 --- a/src/diff/props.js +++ b/src/diff/props.js @@ -52,7 +52,7 @@ export function setProperty(dom, name, value, oldValue, isSvg) { // Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6 else if (name[0] === 'o' && name[1] === 'n') { useCapture = - name !== (name = name.replace(/(PointerCapture)$|Capture$/, '$1')); + name !== (name = name.replace(/(PointerCapture)$|Capture$/i, '$1')); // Infer correct casing for DOM built-in events: if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);