aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-01-21 14:12:35 +0100
committerGitHub <noreply@github.com>2020-01-21 14:12:35 +0100
commit23d53928f383b0e7440bf4b08b7524e6af232fad (patch)
treee3d3b4b78a0e2aa53dfa3a4e4ac57296881f47b7
parent865469f5e60f55feb28469bb0a7526dd22f04b4e (diff)
downloadjquery-23d53928f383b0e7440bf4b08b7524e6af232fad.tar.gz
jquery-23d53928f383b0e7440bf4b08b7524e6af232fad.zip
Ajax: Deprecate AJAX event aliases, inline event/alias into deprecated
A new `src/deprecated` directory makes it possible to exclude some deprecated APIs from a custom build when their respective "parent" module is excluded without keeping that module outside of the `src/deprecated` directory or the `src/deprecated.js` file. Closes gh-4572
-rw-r--r--Gruntfile.js5
-rw-r--r--README.md5
-rw-r--r--src/deprecated.js24
-rw-r--r--src/deprecated/ajax-event-alias.js (renamed from src/event/ajax.js)2
-rw-r--r--src/deprecated/event.js42
-rw-r--r--src/event/alias.js23
-rw-r--r--src/jquery.js1
7 files changed, 50 insertions, 52 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 562d286f6..51f8bc643 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -58,14 +58,15 @@ module.exports = function( grunt ) {
// Exclude specified modules if the module matching the key is removed
removeWith: {
- ajax: [ "manipulation/_evalUrl", "event/ajax" ],
+ ajax: [ "manipulation/_evalUrl", "deprecated/ajax-event-alias" ],
callbacks: [ "deferred" ],
css: [ "effects", "dimensions", "offset" ],
"css/showHide": [ "effects" ],
deferred: {
remove: [ "ajax", "effects", "queue", "core/ready" ],
include: [ "core/ready-no-deferred" ]
- }
+ },
+ event: [ "deprecated/ajax-event-alias", "deprecated/event" ]
}
}
},
diff --git a/README.md b/README.md
index 9302b2f14..865383a87 100644
--- a/README.md
+++ b/README.md
@@ -86,8 +86,7 @@ Some example modules that can be excluded are:
- **deprecated**: Methods documented as deprecated but not yet removed.
- **dimensions**: The `.width()` and `.height()` methods, including `inner-` and `outer-` variations.
- **effects**: The `.animate()` method and its shorthands such as `.slideUp()` or `.hide("slow")`.
-- **event**: The `.on()` and `.off()` methods and all event functionality. Also removes `event/alias`.
-- **event/alias**: All event attaching/triggering shorthands like `.click()` or `.mouseover()`.
+- **event**: The `.on()` and `.off()` methods and all event functionality.
- **event/trigger**: The `.trigger()` and `.triggerHandler()` methods. Used by the **alias** module.
- **offset**: The `.offset()`, `.position()`, `.offsetParent()`, `.scrollLeft()`, and `.scrollTop()` methods.
- **wrap**: The `.wrap()`, `.wrapAll()`, `.wrapInner()`, and `.unwrap()` methods.
@@ -143,7 +142,7 @@ grunt custom:-css
Exclude a bunch of modules:
```bash
-grunt custom:-ajax,-css,-deprecated,-dimensions,-effects,-event/alias,-offset,-wrap
+grunt custom:-ajax/jsonp,-css,-deprecated,-dimensions,-effects,-offset,-wrap
```
There is also a special alias to generate a build with the same configuration as the official jQuery Slim build is generated:
diff --git a/src/deprecated.js b/src/deprecated.js
index b7879c208..be1997321 100644
--- a/src/deprecated.js
+++ b/src/deprecated.js
@@ -2,28 +2,8 @@ import jQuery from "./core.js";
import slice from "./var/slice.js";
import trim from "./var/trim.js";
-import "./event/alias.js";
-
-jQuery.fn.extend( {
-
- bind: function( types, data, fn ) {
- return this.on( types, null, data, fn );
- },
- unbind: function( types, fn ) {
- return this.off( types, null, fn );
- },
-
- delegate: function( selector, types, data, fn ) {
- return this.on( types, selector, data, fn );
- },
- undelegate: function( selector, types, fn ) {
-
- // ( namespace ) or ( selector, types [, fn] )
- return arguments.length === 1 ?
- this.off( selector, "**" ) :
- this.off( types, selector || "**", fn );
- }
-} );
+import "./deprecated/ajax-event-alias.js";
+import "./deprecated/event.js";
// Bind a function to a context, optionally partially applying any
// arguments.
diff --git a/src/event/ajax.js b/src/deprecated/ajax-event-alias.js
index 8c64d9b3e..e4fe11525 100644
--- a/src/event/ajax.js
+++ b/src/deprecated/ajax-event-alias.js
@@ -1,8 +1,8 @@
import jQuery from "../core.js";
+import "../ajax.js";
import "../event.js";
-// Attach a bunch of functions for handling common AJAX events
jQuery.each( [
"ajaxStart",
"ajaxStop",
diff --git a/src/deprecated/event.js b/src/deprecated/event.js
new file mode 100644
index 000000000..7ad4492f0
--- /dev/null
+++ b/src/deprecated/event.js
@@ -0,0 +1,42 @@
+import jQuery from "../core.js";
+
+import "../event.js";
+import "../event/trigger.js";
+
+jQuery.fn.extend( {
+
+ bind: function( types, data, fn ) {
+ return this.on( types, null, data, fn );
+ },
+ unbind: function( types, fn ) {
+ return this.off( types, null, fn );
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.on( types, selector, data, fn );
+ },
+ undelegate: function( selector, types, fn ) {
+
+ // ( namespace ) or ( selector, types [, fn] )
+ return arguments.length === 1 ?
+ this.off( selector, "**" ) :
+ this.off( types, selector || "**", fn );
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+} );
+
+jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup contextmenu" ).split( " " ),
+ function( _i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ return arguments.length > 0 ?
+ this.on( name, null, data, fn ) :
+ this.trigger( name );
+ };
+ } );
diff --git a/src/event/alias.js b/src/event/alias.js
deleted file mode 100644
index 346951b11..000000000
--- a/src/event/alias.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import jQuery from "../core.js";
-
-import "../event.js";
-import "./trigger.js";
-
-jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup contextmenu" ).split( " " ),
- function( _i, name ) {
-
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- return arguments.length > 0 ?
- this.on( name, null, data, fn ) :
- this.trigger( name );
- };
-} );
-
-jQuery.fn.extend( {
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
-} );
diff --git a/src/jquery.js b/src/jquery.js
index 53515267b..3a27fe3ff 100644
--- a/src/jquery.js
+++ b/src/jquery.js
@@ -24,7 +24,6 @@ import "./ajax/jsonp.js";
import "./ajax/load.js";
import "./core/parseXML.js";
import "./core/parseHTML.js";
-import "./event/ajax.js";
import "./effects.js";
import "./effects/animatedSelector.js";
import "./offset.js";