Skip to content

Commit e08b25e

Browse files
authored
Merge branch 'main' into retain-use-id
2 parents fe23841 + 13b0afb commit e08b25e

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

compat/test/browser/events.test.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { render } from 'preact';
22
import {
33
setupScratch,
44
teardown,
5-
createEvent
5+
createEvent,
6+
supportsPassiveEvents
67
} from '../../../test/_util/helpers';
78

89
import React, { createElement } from 'preact/compat';
@@ -309,4 +310,24 @@ describe('preact/compat events', () => {
309310
scratch.firstChild.dispatchEvent(createEvent('focusout'));
310311
expect(spy).to.be.calledOnce;
311312
});
313+
314+
if (supportsPassiveEvents()) {
315+
it('should use capturing for event props ending with *Capture', () => {
316+
let click = sinon.spy();
317+
318+
render(
319+
<div onTouchMoveCapture={click}>
320+
<button type="button">Click me</button>
321+
</div>,
322+
scratch
323+
);
324+
325+
expect(proto.addEventListener).to.have.been.calledOnce;
326+
expect(proto.addEventListener).to.have.been.calledWithExactly(
327+
'touchmove',
328+
sinon.match.func,
329+
true
330+
);
331+
});
332+
}
312333
});

src/diff/props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
5252
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
5353
else if (name[0] === 'o' && name[1] === 'n') {
5454
useCapture =
55-
name !== (name = name.replace(/(PointerCapture)$|Capture$/, '$1'));
55+
name !== (name = name.replace(/(PointerCapture)$|Capture$/i, '$1'));
5656

5757
// Infer correct casing for DOM built-in events:
5858
if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);

0 commit comments

Comments
 (0)