Skip to content

Commit 637e66c

Browse files
committed
Build: Update jQuery Migrate from 3.0.0 to 3.1.0
1 parent 3de98b9 commit 637e66c

File tree

3 files changed

+182
-44
lines changed

3 files changed

+182
-44
lines changed

external/jquery-migrate-3.0.0/LICENSE.txt renamed to external/jquery-migrate-3.1.0/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright jQuery Foundation and other contributors, https://jquery.org/
1+
Copyright OpenJS Foundation and other contributors, https://openjsf.org/
22

33
This software consists of voluntary contributions made by many
44
individuals. For exact contribution history, see the revision history

external/jquery-migrate-3.0.0/jquery-migrate.js renamed to external/jquery-migrate-3.1.0/jquery-migrate.js

Lines changed: 180 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,74 @@
11
/*!
2-
* jQuery Migrate - v3.0.0 - 2016-06-09
3-
* Copyright jQuery Foundation and other contributors
2+
* jQuery Migrate - v3.1.0 - 2019-06-08
3+
* Copyright OpenJS Foundation and other contributors
44
*/
5-
(function( jQuery, window ) {
5+
;( function( factory ) {
6+
if ( typeof define === "function" && define.amd ) {
7+
8+
// AMD. Register as an anonymous module.
9+
define( [ "jquery" ], function ( jQuery ) {
10+
return factory( jQuery, window );
11+
} );
12+
} else if ( typeof module === "object" && module.exports ) {
13+
14+
// Node/CommonJS
15+
// eslint-disable-next-line no-undef
16+
module.exports = factory( require( "jquery" ), window );
17+
} else {
18+
19+
// Browser globals
20+
factory( jQuery, window );
21+
}
22+
} )( function( jQuery, window ) {
623
"use strict";
724

825

9-
jQuery.migrateVersion = "3.0.0";
26+
jQuery.migrateVersion = "3.1.0";
27+
28+
/* exported jQueryVersionSince, compareVersions */
1029

30+
// Returns 0 if v1 == v2, -1 if v1 < v2, 1 if v1 > v2
31+
function compareVersions( v1, v2 ) {
32+
var rVersionParts = /^(\d+)\.(\d+)\.(\d+)/,
33+
v1p = rVersionParts.exec( v1 ) || [ ],
34+
v2p = rVersionParts.exec( v2 ) || [ ];
35+
36+
for ( var i = 1; i <= 3; i++ ) {
37+
if ( +v1p[ i ] > +v2p[ i ] ) {
38+
return 1;
39+
}
40+
if ( +v1p[ i ] < +v2p[ i ] ) {
41+
return -1;
42+
}
43+
}
44+
return 0;
45+
}
46+
47+
function jQueryVersionSince( version ) {
48+
return compareVersions( jQuery.fn.jquery, version ) >= 0;
49+
}
50+
51+
/* exported migrateWarn, migrateWarnFunc, migrateWarnProp */
1152

1253
( function() {
1354

1455
// Support: IE9 only
1556
// IE9 only creates console object when dev tools are first opened
16-
// Also, avoid Function#bind here to simplify PhantomJS usage
17-
var log = window.console && window.console.log &&
18-
function() { window.console.log.apply( window.console, arguments ); },
19-
rbadVersions = /^[12]\./;
20-
21-
if ( !log ) {
57+
// IE9 console is a host object, callable but doesn't have .apply()
58+
if ( !window.console || !window.console.log ) {
2259
return;
2360
}
2461

2562
// Need jQuery 3.0.0+ and no older Migrate loaded
26-
if ( !jQuery || rbadVersions.test( jQuery.fn.jquery ) ) {
27-
log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
63+
if ( !jQuery || !jQueryVersionSince( "3.0.0" ) ) {
64+
window.console.log( "JQMIGRATE: jQuery 3.0.0+ REQUIRED" );
2865
}
2966
if ( jQuery.migrateWarnings ) {
30-
log( "JQMIGRATE: Migrate plugin loaded multiple times" );
67+
window.console.log( "JQMIGRATE: Migrate plugin loaded multiple times" );
3168
}
3269

3370
// Show a message on the console so devs know we're active
34-
log( "JQMIGRATE: Migrate is installed" +
71+
window.console.log( "JQMIGRATE: Migrate is installed" +
3572
( jQuery.migrateMute ? "" : " with logging active" ) +
3673
", version " + jQuery.migrateVersion );
3774

@@ -74,11 +111,22 @@ function migrateWarnProp( obj, prop, value, msg ) {
74111
get: function() {
75112
migrateWarn( msg );
76113
return value;
114+
},
115+
set: function( newValue ) {
116+
migrateWarn( msg );
117+
value = newValue;
77118
}
78119
} );
79120
}
80121

81-
if ( document.compatMode === "BackCompat" ) {
122+
function migrateWarnFunc( obj, prop, newFunc, msg ) {
123+
obj[ prop ] = function() {
124+
migrateWarn( msg );
125+
return newFunc.apply( this, arguments );
126+
};
127+
}
128+
129+
if ( window.document.compatMode === "BackCompat" ) {
82130

83131
// JQuery has never supported or tested Quirks Mode
84132
migrateWarn( "jQuery is not compatible with Quirks Mode" );
@@ -115,7 +163,7 @@ jQuery.find = function( selector ) {
115163
// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
116164
// First see if qS thinks it's a valid selector, if so avoid a false positive
117165
try {
118-
document.querySelector( selector );
166+
window.document.querySelector( selector );
119167
} catch ( err1 ) {
120168

121169
// Didn't *look* valid to qSA, warn and try quoting what we think is the value
@@ -126,7 +174,7 @@ jQuery.find = function( selector ) {
126174
// If the regexp *may* have created an invalid selector, don't update it
127175
// Note that there may be false alarms if selector uses jQuery extensions
128176
try {
129-
document.querySelector( selector );
177+
window.document.querySelector( selector );
130178
migrateWarn( "Attribute selector with '#' must be quoted: " + args[ 0 ] );
131179
args[ 0 ] = selector;
132180
} catch ( err2 ) {
@@ -148,7 +196,7 @@ for ( findProp in oldFind ) {
148196

149197
// The number of elements contained in the matched element set
150198
jQuery.fn.size = function() {
151-
migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
199+
migrateWarn( "jQuery.fn.size() is deprecated and removed; use the .length property" );
152200
return this.length;
153201
};
154202

@@ -175,14 +223,32 @@ jQuery.isNumeric = function( val ) {
175223
return oldValue;
176224
};
177225

178-
migrateWarnProp( jQuery, "unique", jQuery.uniqueSort,
179-
"jQuery.unique is deprecated, use jQuery.uniqueSort" );
226+
if ( jQueryVersionSince( "3.3.0" ) ) {
227+
migrateWarnFunc( jQuery, "isWindow",
228+
function( obj ) {
229+
return obj != null && obj === obj.window;
230+
},
231+
"jQuery.isWindow() is deprecated"
232+
);
233+
}
234+
235+
migrateWarnFunc( jQuery, "holdReady", jQuery.holdReady,
236+
"jQuery.holdReady is deprecated" );
237+
238+
migrateWarnFunc( jQuery, "unique", jQuery.uniqueSort,
239+
"jQuery.unique is deprecated; use jQuery.uniqueSort" );
180240

181241
// Now jQuery.expr.pseudos is the standard incantation
182242
migrateWarnProp( jQuery.expr, "filters", jQuery.expr.pseudos,
183-
"jQuery.expr.filters is now jQuery.expr.pseudos" );
243+
"jQuery.expr.filters is deprecated; use jQuery.expr.pseudos" );
184244
migrateWarnProp( jQuery.expr, ":", jQuery.expr.pseudos,
185-
"jQuery.expr[\":\"] is now jQuery.expr.pseudos" );
245+
"jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos" );
246+
247+
// Prior to jQuery 3.2 there were internal refs so we don't warn there
248+
if ( jQueryVersionSince( "3.2.0" ) ) {
249+
migrateWarnFunc( jQuery, "nodeName", jQuery.nodeName,
250+
"jQuery.nodeName is deprecated" );
251+
}
186252

187253

188254
var oldAjax = jQuery.ajax;
@@ -192,11 +258,11 @@ jQuery.ajax = function( ) {
192258

193259
// Be sure we got a jQXHR (e.g., not sync)
194260
if ( jQXHR.promise ) {
195-
migrateWarnProp( jQXHR, "success", jQXHR.done,
261+
migrateWarnFunc( jQXHR, "success", jQXHR.done,
196262
"jQXHR.success is deprecated and removed" );
197-
migrateWarnProp( jQXHR, "error", jQXHR.fail,
263+
migrateWarnFunc( jQXHR, "error", jQXHR.fail,
198264
"jQXHR.error is deprecated and removed" );
199-
migrateWarnProp( jQXHR, "complete", jQXHR.always,
265+
migrateWarnFunc( jQXHR, "complete", jQXHR.always,
200266
"jQXHR.complete is deprecated and removed" );
201267
}
202268

@@ -211,7 +277,7 @@ var oldRemoveAttr = jQuery.fn.removeAttr,
211277
jQuery.fn.removeAttr = function( name ) {
212278
var self = this;
213279

214-
jQuery.each( name.match( rmatchNonSpace ), function( i, attr ) {
280+
jQuery.each( name.match( rmatchNonSpace ), function( _i, attr ) {
215281
if ( jQuery.expr.match.bool.test( attr ) ) {
216282
migrateWarn( "jQuery.fn.removeAttr no longer sets boolean properties: " + attr );
217283
self.prop( attr, false );
@@ -302,8 +368,26 @@ var oldData = jQuery.data;
302368
jQuery.data = function( elem, name, value ) {
303369
var curData;
304370

371+
// Name can be an object, and each entry in the object is meant to be set as data
372+
if ( name && typeof name === "object" && arguments.length === 2 ) {
373+
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
374+
var sameKeys = {};
375+
for ( var key in name ) {
376+
if ( key !== jQuery.camelCase( key ) ) {
377+
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + key );
378+
curData[ key ] = name[ key ];
379+
} else {
380+
sameKeys[ key ] = name[ key ];
381+
}
382+
}
383+
384+
oldData.call( this, elem, sameKeys );
385+
386+
return name;
387+
}
388+
305389
// If the name is transformed, look for the un-transformed name in the data object
306-
if ( name && name !== jQuery.camelCase( name ) ) {
390+
if ( name && typeof name === "string" && name !== jQuery.camelCase( name ) ) {
307391
curData = jQuery.hasData( elem ) && oldData.call( this, elem );
308392
if ( curData && name in curData ) {
309393
migrateWarn( "jQuery.data() always sets/gets camelCased names: " + name );
@@ -318,30 +402,55 @@ jQuery.data = function( elem, name, value ) {
318402
};
319403

320404
var oldTweenRun = jQuery.Tween.prototype.run;
405+
var linearEasing = function( pct ) {
406+
return pct;
407+
};
321408

322-
jQuery.Tween.prototype.run = function( percent ) {
409+
jQuery.Tween.prototype.run = function( ) {
323410
if ( jQuery.easing[ this.easing ].length > 1 ) {
324411
migrateWarn(
325-
"easing function " +
326-
"\"jQuery.easing." + this.easing.toString() +
327-
"\" should use only first argument"
412+
"'jQuery.easing." + this.easing.toString() + "' should use only one argument"
328413
);
329414

330-
jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
331-
jQuery.easing,
332-
percent, this.options.duration * percent, 0, 1, this.options.duration
333-
);
415+
jQuery.easing[ this.easing ] = linearEasing;
334416
}
335417

336418
oldTweenRun.apply( this, arguments );
337419
};
338420

421+
var intervalValue = jQuery.fx.interval || 13,
422+
intervalMsg = "jQuery.fx.interval is deprecated";
423+
424+
// Support: IE9, Android <=4.4
425+
// Avoid false positives on browsers that lack rAF
426+
// Don't warn if document is hidden, jQuery uses setTimeout (#292)
427+
if ( window.requestAnimationFrame ) {
428+
Object.defineProperty( jQuery.fx, "interval", {
429+
configurable: true,
430+
enumerable: true,
431+
get: function() {
432+
if ( !window.document.hidden ) {
433+
migrateWarn( intervalMsg );
434+
}
435+
return intervalValue;
436+
},
437+
set: function( newValue ) {
438+
migrateWarn( intervalMsg );
439+
intervalValue = newValue;
440+
}
441+
} );
442+
}
443+
339444
var oldLoad = jQuery.fn.load,
445+
oldEventAdd = jQuery.event.add,
340446
originalFix = jQuery.event.fix;
341447

342448
jQuery.event.props = [];
343449
jQuery.event.fixHooks = {};
344450

451+
migrateWarnProp( jQuery.event.props, "concat", jQuery.event.props.concat,
452+
"jQuery.event.props.concat() is deprecated and removed" );
453+
345454
jQuery.event.fix = function( originalEvent ) {
346455
var event,
347456
type = originalEvent.type,
@@ -360,7 +469,7 @@ jQuery.event.fix = function( originalEvent ) {
360469
migrateWarn( "jQuery.event.fixHooks are deprecated and removed: " + type );
361470
if ( ( props = fixHook.props ) && props.length ) {
362471
while ( props.length ) {
363-
jQuery.event.addProp( props.pop() );
472+
jQuery.event.addProp( props.pop() );
364473
}
365474
}
366475
}
@@ -370,6 +479,15 @@ jQuery.event.fix = function( originalEvent ) {
370479
return fixHook && fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
371480
};
372481

482+
jQuery.event.add = function( elem, types ) {
483+
484+
// This misses the multiple-types case but that seems awfully rare
485+
if ( elem === window && types === "load" && window.document.readyState === "complete" ) {
486+
migrateWarn( "jQuery(window).on('load'...) called after load event occurred" );
487+
}
488+
return oldEventAdd.apply( this, arguments );
489+
};
490+
373491
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
374492

375493
jQuery.fn[ name ] = function() {
@@ -400,14 +518,28 @@ jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
400518

401519
} );
402520

521+
jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
522+
"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
523+
"change select submit keydown keypress keyup contextmenu" ).split( " " ),
524+
function( _i, name ) {
525+
526+
// Handle event binding
527+
jQuery.fn[ name ] = function( data, fn ) {
528+
migrateWarn( "jQuery.fn." + name + "() event shorthand is deprecated" );
529+
return arguments.length > 0 ?
530+
this.on( name, null, data, fn ) :
531+
this.trigger( name );
532+
};
533+
} );
534+
403535
// Trigger "ready" event only once, on document ready
404536
jQuery( function() {
405-
jQuery( document ).triggerHandler( "ready" );
537+
jQuery( window.document ).triggerHandler( "ready" );
406538
} );
407539

408540
jQuery.event.special.ready = {
409541
setup: function() {
410-
if ( this === document ) {
542+
if ( this === window.document ) {
411543
migrateWarn( "'ready' event is deprecated" );
412544
}
413545
}
@@ -432,6 +564,10 @@ jQuery.fn.extend( {
432564
return arguments.length === 1 ?
433565
this.off( selector, "**" ) :
434566
this.off( types, selector || "**", fn );
567+
},
568+
hover: function( fnOver, fnOut ) {
569+
migrateWarn( "jQuery.fn.hover() is deprecated" );
570+
return this.on( "mouseenter", fnOver ).on( "mouseleave", fnOut || fnOver );
435571
}
436572
} );
437573

@@ -448,7 +584,7 @@ jQuery.fn.offset = function() {
448584
return origin;
449585
}
450586

451-
docElem = ( elem.ownerDocument || document ).documentElement;
587+
docElem = ( elem.ownerDocument || window.document ).documentElement;
452588
if ( !jQuery.contains( docElem, elem ) ) {
453589
migrateWarn( "jQuery.fn.offset() requires an element connected to a document" );
454590
return origin;
@@ -475,7 +611,7 @@ jQuery.param = function( data, traditional ) {
475611
var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack;
476612

477613
jQuery.fn.andSelf = function() {
478-
migrateWarn( "jQuery.fn.andSelf() replaced by jQuery.fn.addBack()" );
614+
migrateWarn( "jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()" );
479615
return oldSelf.apply( this, arguments );
480616
};
481617

@@ -535,6 +671,8 @@ jQuery.Deferred = function( func ) {
535671
return deferred;
536672
};
537673

674+
// Preserve handler of uncaught exceptions in promise chains
675+
jQuery.Deferred.exceptionHook = oldDeferred.exceptionHook;
538676

539-
540-
})( jQuery, window );
677+
return jQuery;
678+
} );

0 commit comments

Comments
 (0)