]> source.dussan.org Git - jquery.git/commit
Event: Don't break focus triggering after `.on(focus).off(focus)`
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>
Mon, 10 May 2021 16:59:14 +0000 (18:59 +0200)
committerGitHub <noreply@github.com>
Mon, 10 May 2021 16:59:14 +0000 (18:59 +0200)
commite539bac79e666bba95bba86d690b4e609dca2286
treef9759b616671b1fa56f36af3832cfde61a3099aa
parenta70274632dc19ff4a64d7bb7657a2cc647ff38b9
Event: Don't break focus triggering after `.on(focus).off(focus)`

The `_default` function in the special event settings for focus/blur has
always returned `true` since gh-4813 as the event was already being fired
from `leverageNative`. However, that only works if there's an active handler
on that element; this made a quick consecutive call:

```js
elem.on( "focus", function() {} ).off( "focus" );
```

make subsequent `.trigger( "focus" )` calls to not do any triggering.

The solution, already used in a similar `_default` method for the `click` event,
is to check for the `dataPriv` entry on the element for the focus event
(similarly for blur).

Fixes gh-4867
Closes gh-4885
src/event.js
test/unit/event.js