aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-12-09 19:50:14 +0100
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-12-09 19:53:17 +0100
commitf36f6abbb3e9e4d7d3729272ffb10b4c2c382919 (patch)
treedf6bb3bb23a52b026a4f16f6d81475d45ee8c58a /src/event.js
parentc79e1d5fefc50b1df0a1c2ca3f06b567e79c0f9b (diff)
downloadjquery-f36f6abbb3e9e4d7d3729272ffb10b4c2c382919.tar.gz
jquery-f36f6abbb3e9e4d7d3729272ffb10b4c2c382919.zip
Event: Only attach events to objects that accept data - for real
There was a check in jQuery.event.add that was supposed to make it a noop for objects that don't accept data like text or comment nodes. The problem was the check was incorrect: it assumed `dataPriv.get( elem )` returns a falsy value for an `elem` that doesn't accept data but that's not the case - we get an empty object then. The check was changed to use `acceptData` directly. (cherry picked from d5c505e35d8c74ce8e9d99731a1a7eab0e0d911c) Fixes gh-4397 Closes gh-4558
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/event.js b/src/event.js
index 3ff11ad0b..79abf5614 100644
--- a/src/event.js
+++ b/src/event.js
@@ -6,13 +6,14 @@ define( [
"./var/rnothtmlwhite",
"./var/rcheckableType",
"./var/slice",
+ "./data/var/acceptData",
"./data/var/dataPriv",
"./core/nodeName",
"./core/init",
"./selector"
], function( jQuery, document, documentElement, isFunction, rnothtmlwhite,
- rcheckableType, slice, dataPriv, nodeName ) {
+ rcheckableType, slice, acceptData, dataPriv, nodeName ) {
"use strict";
@@ -124,8 +125,8 @@ jQuery.event = {
special, handlers, type, namespaces, origType,
elemData = dataPriv.get( elem );
- // Don't attach events to noData or text/comment nodes (but allow plain objects)
- if ( !elemData ) {
+ // Only attach events to objects that accept data
+ if ( !acceptData( elem ) ) {
return;
}