Skip to content

Commit 3481a12

Browse files
committed
Event: Reimplement APIs deprecated in jQuery 3.0/3.1
This fixes tests with 3.0/3.1 slim builds.
1 parent 084a64e commit 3481a12

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/jquery/event.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,25 @@ jQuery.event.special.ready = {
114114
}
115115
};
116116

117-
migratePatchAndWarnFunc( jQuery.fn, "bind", jQuery.fn.bind,
118-
"pre-on-methods", "jQuery.fn.bind() is deprecated" );
119-
migratePatchAndWarnFunc( jQuery.fn, "unbind", jQuery.fn.unbind,
120-
"pre-on-methods", "jQuery.fn.unbind() is deprecated" );
121-
migratePatchAndWarnFunc( jQuery.fn, "delegate", jQuery.fn.delegate,
122-
"pre-on-methods", "jQuery.fn.delegate() is deprecated" );
123-
migratePatchAndWarnFunc( jQuery.fn, "undelegate", jQuery.fn.undelegate,
124-
"pre-on-methods", "jQuery.fn.undelegate() is deprecated" );
125-
117+
// Support: jQuery <3.2.0 only
118+
// jQuery 3.0.x & 3.1.x used to not include the deprecated module in the slim build.
119+
// To maintain compatibility with those versions, we need to reimplement APIs
120+
// deprecated in them.
121+
// See https://github.com/jquery/jquery/blob/3.1.1/src/deprecated.js
122+
migratePatchAndWarnFunc( jQuery.fn, "bind", function( types, data, fn ) {
123+
return this.on( types, null, data, fn );
124+
}, "pre-on-methods", "jQuery.fn.bind() is deprecated" );
125+
migratePatchAndWarnFunc( jQuery.fn, "unbind", function( types, fn ) {
126+
return this.off( types, null, fn );
127+
}, "pre-on-methods", "jQuery.fn.unbind() is deprecated" );
128+
migratePatchAndWarnFunc( jQuery.fn, "delegate", function( selector, types, data, fn ) {
129+
return this.on( types, selector, data, fn );
130+
}, "pre-on-methods", "jQuery.fn.delegate() is deprecated" );
131+
migratePatchAndWarnFunc( jQuery.fn, "undelegate", function( selector, types, fn ) {
132+
return arguments.length === 1 ?
133+
this.off( selector, "**" ) :
134+
this.off( types, selector || "**", fn );
135+
}, "pre-on-methods", "jQuery.fn.undelegate() is deprecated" );
126136
migratePatchAndWarnFunc( jQuery.fn, "hover", function( fnOver, fnOut ) {
127137
return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver );
128138
}, "pre-on-methods", "jQuery.fn.hover() is deprecated" );

0 commit comments

Comments
 (0)