Skip to content

Commit 68cabde

Browse files
authored
fix(jsx/dom): remove lookbehind assertion in event regexp (#2524)
* fix(jsx/dom): remove lookbehind assertion in event regexp for iOS Safari 16.3 * chore: denoify
1 parent ed51b0b commit 68cabde

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

deno_dist/jsx/dom/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let nameSpaceContext: JSXContext<string> | undefined = undefined
9090
const isNodeString = (node: Node): node is NodeString => Array.isArray(node)
9191

9292
const getEventSpec = (key: string): [string, boolean] | undefined => {
93-
const match = key.match(/^on([A-Z][a-zA-Z]+?)((?<!Pointer)Capture)?$/)
93+
const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/)
9494
if (match) {
9595
const [, eventName, capture] = match
9696
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture]

src/jsx/dom/index.test.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,33 @@ describe('DOM', () => {
598598
root.querySelector('button')?.click()
599599
expect(clicked).toEqual(['div', 'button', 'button'])
600600
})
601+
602+
it('onGotPointerCapture', async () => {
603+
const App = () => {
604+
return <div onGotPointerCapture={() => {}}></div>
605+
}
606+
const addEventListenerSpy = vi.spyOn(dom.window.Node.prototype, 'addEventListener')
607+
render(<App />, root)
608+
expect(addEventListenerSpy).toHaveBeenCalledOnce()
609+
expect(addEventListenerSpy).toHaveBeenCalledWith(
610+
'gotpointercapture',
611+
expect.any(Function),
612+
false
613+
)
614+
})
615+
it('onGotPointerCaptureCapture', async () => {
616+
const App = () => {
617+
return <div onGotPointerCaptureCapture={() => {}}></div>
618+
}
619+
const addEventListenerSpy = vi.spyOn(dom.window.Node.prototype, 'addEventListener')
620+
render(<App />, root)
621+
expect(addEventListenerSpy).toHaveBeenCalledOnce()
622+
expect(addEventListenerSpy).toHaveBeenCalledWith(
623+
'gotpointercapture',
624+
expect.any(Function),
625+
true
626+
)
627+
})
601628
})
602629

603630
it('simple Counter', async () => {

src/jsx/dom/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let nameSpaceContext: JSXContext<string> | undefined = undefined
9090
const isNodeString = (node: Node): node is NodeString => Array.isArray(node)
9191

9292
const getEventSpec = (key: string): [string, boolean] | undefined => {
93-
const match = key.match(/^on([A-Z][a-zA-Z]+?)((?<!Pointer)Capture)?$/)
93+
const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/)
9494
if (match) {
9595
const [, eventName, capture] = match
9696
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture]

0 commit comments

Comments
 (0)