]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/jquery/jquery-migrate.js
e3538e9c8a351c82eed445d002ccf9100de17519
[autoinstalls/wordpress.git] / wp-includes / js / jquery / jquery-migrate.js
1 /*!
2  * jQuery Migrate - v1.4.0 - 2016-02-26
3  * Copyright jQuery Foundation and other contributors
4  */
5 (function( jQuery, window, undefined ) {
6 // See http://bugs.jquery.com/ticket/13335
7 // "use strict";
8
9
10 jQuery.migrateVersion = "1.4.0";
11
12
13 var warnedAbout = {};
14
15 // List of warnings already given; public read only
16 jQuery.migrateWarnings = [];
17
18 // Set to true to prevent console output; migrateWarnings still maintained
19 // jQuery.migrateMute = false;
20
21 // Show a message on the console so devs know we're active
22 if ( window.console && window.console.log ) {
23         window.console.log( "JQMIGRATE: Migrate is installed" +
24                 ( jQuery.migrateMute ? "" : " with logging active" ) +
25                 ", version " + jQuery.migrateVersion );
26 }
27
28 // Set to false to disable traces that appear with warnings
29 if ( jQuery.migrateTrace === undefined ) {
30         jQuery.migrateTrace = true;
31 }
32
33 // Forget any warnings we've already given; public
34 jQuery.migrateReset = function() {
35         warnedAbout = {};
36         jQuery.migrateWarnings.length = 0;
37 };
38
39 function migrateWarn( msg) {
40         var console = window.console;
41         if ( !warnedAbout[ msg ] ) {
42                 warnedAbout[ msg ] = true;
43                 jQuery.migrateWarnings.push( msg );
44                 if ( console && console.warn && !jQuery.migrateMute ) {
45                         console.warn( "JQMIGRATE: " + msg );
46                         if ( jQuery.migrateTrace && console.trace ) {
47                                 console.trace();
48                         }
49                 }
50         }
51 }
52
53 function migrateWarnProp( obj, prop, value, msg ) {
54         if ( Object.defineProperty ) {
55                 // On ES5 browsers (non-oldIE), warn if the code tries to get prop;
56                 // allow property to be overwritten in case some other plugin wants it
57                 try {
58                         Object.defineProperty( obj, prop, {
59                                 configurable: true,
60                                 enumerable: true,
61                                 get: function() {
62                                         migrateWarn( msg );
63                                         return value;
64                                 },
65                                 set: function( newValue ) {
66                                         migrateWarn( msg );
67                                         value = newValue;
68                                 }
69                         });
70                         return;
71                 } catch( err ) {
72                         // IE8 is a dope about Object.defineProperty, can't warn there
73                 }
74         }
75
76         // Non-ES5 (or broken) browser; just set the property
77         jQuery._definePropertyBroken = true;
78         obj[ prop ] = value;
79 }
80
81 if ( document.compatMode === "BackCompat" ) {
82         // jQuery has never supported or tested Quirks Mode
83         migrateWarn( "jQuery is not compatible with Quirks Mode" );
84 }
85
86
87 var attrFn = jQuery( "<input/>", { size: 1 } ).attr("size") && jQuery.attrFn,
88         oldAttr = jQuery.attr,
89         valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||
90                 function() { return null; },
91         valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||
92                 function() { return undefined; },
93         rnoType = /^(?:input|button)$/i,
94         rnoAttrNodeType = /^[238]$/,
95         rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
96         ruseDefault = /^(?:checked|selected)$/i;
97
98 // jQuery.attrFn
99 migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" );
100
101 jQuery.attr = function( elem, name, value, pass ) {
102         var lowerName = name.toLowerCase(),
103                 nType = elem && elem.nodeType;
104
105         if ( pass ) {
106                 // Since pass is used internally, we only warn for new jQuery
107                 // versions where there isn't a pass arg in the formal params
108                 if ( oldAttr.length < 4 ) {
109                         migrateWarn("jQuery.fn.attr( props, pass ) is deprecated");
110                 }
111                 if ( elem && !rnoAttrNodeType.test( nType ) &&
112                         (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {
113                         return jQuery( elem )[ name ]( value );
114                 }
115         }
116
117         // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking
118         // for disconnected elements we don't warn on $( "<button>", { type: "button" } ).
119         if ( name === "type" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {
120                 migrateWarn("Can't change the 'type' of an input or button in IE 6/7/8");
121         }
122
123         // Restore boolHook for boolean property/attribute synchronization
124         if ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {
125                 jQuery.attrHooks[ lowerName ] = {
126                         get: function( elem, name ) {
127                                 // Align boolean attributes with corresponding properties
128                                 // Fall back to attribute presence where some booleans are not supported
129                                 var attrNode,
130                                         property = jQuery.prop( elem, name );
131                                 return property === true || typeof property !== "boolean" &&
132                                         ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
133
134                                         name.toLowerCase() :
135                                         undefined;
136                         },
137                         set: function( elem, value, name ) {
138                                 var propName;
139                                 if ( value === false ) {
140                                         // Remove boolean attributes when set to false
141                                         jQuery.removeAttr( elem, name );
142                                 } else {
143                                         // value is true since we know at this point it's type boolean and not false
144                                         // Set boolean attributes to the same name and set the DOM property
145                                         propName = jQuery.propFix[ name ] || name;
146                                         if ( propName in elem ) {
147                                                 // Only set the IDL specifically if it already exists on the element
148                                                 elem[ propName ] = true;
149                                         }
150
151                                         elem.setAttribute( name, name.toLowerCase() );
152                                 }
153                                 return name;
154                         }
155                 };
156
157                 // Warn only for attributes that can remain distinct from their properties post-1.9
158                 if ( ruseDefault.test( lowerName ) ) {
159                         migrateWarn( "jQuery.fn.attr('" + lowerName + "') might use property instead of attribute" );
160                 }
161         }
162
163         return oldAttr.call( jQuery, elem, name, value );
164 };
165
166 // attrHooks: value
167 jQuery.attrHooks.value = {
168         get: function( elem, name ) {
169                 var nodeName = ( elem.nodeName || "" ).toLowerCase();
170                 if ( nodeName === "button" ) {
171                         return valueAttrGet.apply( this, arguments );
172                 }
173                 if ( nodeName !== "input" && nodeName !== "option" ) {
174                         migrateWarn("jQuery.fn.attr('value') no longer gets properties");
175                 }
176                 return name in elem ?
177                         elem.value :
178                         null;
179         },
180         set: function( elem, value ) {
181                 var nodeName = ( elem.nodeName || "" ).toLowerCase();
182                 if ( nodeName === "button" ) {
183                         return valueAttrSet.apply( this, arguments );
184                 }
185                 if ( nodeName !== "input" && nodeName !== "option" ) {
186                         migrateWarn("jQuery.fn.attr('value', val) no longer sets properties");
187                 }
188                 // Does not return so that setAttribute is also used
189                 elem.value = value;
190         }
191 };
192
193
194 var matched, browser,
195         oldInit = jQuery.fn.init,
196         oldParseJSON = jQuery.parseJSON,
197         rspaceAngle = /^\s*</,
198         rattrHash = /\[\s*\w+\s*[~|^$*]?=\s*(?![\s'"])[^#\]]*#/,
199         // Note: XSS check is done below after string is trimmed
200         rquickExpr = /^([^<]*)(<[\w\W]+>)([^>]*)$/;
201
202 // $(html) "looks like html" rule change
203 jQuery.fn.init = function( selector, context, rootjQuery ) {
204         var match, ret;
205
206         if ( selector && typeof selector === "string" && !jQuery.isPlainObject( context ) &&
207                         (match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {
208                 // This is an HTML string according to the "old" rules; is it still?
209                 if ( !rspaceAngle.test( selector ) ) {
210                         migrateWarn("$(html) HTML strings must start with '<' character");
211                 }
212                 if ( match[ 3 ] ) {
213                         migrateWarn("$(html) HTML text after last tag is ignored");
214                 }
215
216                 // Consistently reject any HTML-like string starting with a hash (#9521)
217                 // Note that this may break jQuery 1.6.x code that otherwise would work.
218                 if ( match[ 0 ].charAt( 0 ) === "#" ) {
219                         migrateWarn("HTML string cannot start with a '#' character");
220                         jQuery.error("JQMIGRATE: Invalid selector string (XSS)");
221                 }
222                 // Now process using loose rules; let pre-1.8 play too
223                 if ( context && context.context ) {
224                         // jQuery object as context; parseHTML expects a DOM object
225                         context = context.context;
226                 }
227                 if ( jQuery.parseHTML ) {
228                         return oldInit.call( this,
229                                         jQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||
230                                                 context || document, true ), context, rootjQuery );
231                 }
232         }
233
234         if ( selector === "#" ) {
235
236                 // jQuery( "#" ) is a bogus ID selector, but it returned an empty set before jQuery 3.0
237                 migrateWarn( "jQuery( '#' ) is not a valid selector" );
238                 selector = [];
239
240         } else if ( rattrHash.test( selector ) ) {
241
242                 // The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0
243                 // Note that this doesn't actually fix the selector due to potential false positives
244                 migrateWarn( "Attribute selectors with '#' must be quoted: '" + selector + "'" );
245         }
246
247         ret = oldInit.apply( this, arguments );
248
249         // Fill in selector and context properties so .live() works
250         if ( selector && selector.selector !== undefined ) {
251                 // A jQuery object, copy its properties
252                 ret.selector = selector.selector;
253                 ret.context = selector.context;
254
255         } else {
256                 ret.selector = typeof selector === "string" ? selector : "";
257                 if ( selector ) {
258                         ret.context = selector.nodeType? selector : context || document;
259                 }
260         }
261
262         return ret;
263 };
264 jQuery.fn.init.prototype = jQuery.fn;
265
266 // Let $.parseJSON(falsy_value) return null
267 jQuery.parseJSON = function( json ) {
268         if ( !json ) {
269                 migrateWarn("jQuery.parseJSON requires a valid JSON string");
270                 return null;
271         }
272         return oldParseJSON.apply( this, arguments );
273 };
274
275 jQuery.uaMatch = function( ua ) {
276         ua = ua.toLowerCase();
277
278         var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
279                 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
280                 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
281                 /(msie) ([\w.]+)/.exec( ua ) ||
282                 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
283                 [];
284
285         return {
286                 browser: match[ 1 ] || "",
287                 version: match[ 2 ] || "0"
288         };
289 };
290
291 // Don't clobber any existing jQuery.browser in case it's different
292 if ( !jQuery.browser ) {
293         matched = jQuery.uaMatch( navigator.userAgent );
294         browser = {};
295
296         if ( matched.browser ) {
297                 browser[ matched.browser ] = true;
298                 browser.version = matched.version;
299         }
300
301         // Chrome is Webkit, but Webkit is also Safari.
302         if ( browser.chrome ) {
303                 browser.webkit = true;
304         } else if ( browser.webkit ) {
305                 browser.safari = true;
306         }
307
308         jQuery.browser = browser;
309 }
310
311 // Warn if the code tries to get jQuery.browser
312 migrateWarnProp( jQuery, "browser", jQuery.browser, "jQuery.browser is deprecated" );
313
314 // jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7
315 jQuery.boxModel = jQuery.support.boxModel = (document.compatMode === "CSS1Compat");
316 migrateWarnProp( jQuery, "boxModel", jQuery.boxModel, "jQuery.boxModel is deprecated" );
317 migrateWarnProp( jQuery.support, "boxModel", jQuery.support.boxModel, "jQuery.support.boxModel is deprecated" );
318
319 jQuery.sub = function() {
320         function jQuerySub( selector, context ) {
321                 return new jQuerySub.fn.init( selector, context );
322         }
323         jQuery.extend( true, jQuerySub, this );
324         jQuerySub.superclass = this;
325         jQuerySub.fn = jQuerySub.prototype = this();
326         jQuerySub.fn.constructor = jQuerySub;
327         jQuerySub.sub = this.sub;
328         jQuerySub.fn.init = function init( selector, context ) {
329                 var instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );
330                 return instance instanceof jQuerySub ?
331                         instance :
332                         jQuerySub( instance );
333         };
334         jQuerySub.fn.init.prototype = jQuerySub.fn;
335         var rootjQuerySub = jQuerySub(document);
336         migrateWarn( "jQuery.sub() is deprecated" );
337         return jQuerySub;
338 };
339
340 // The number of elements contained in the matched element set
341 jQuery.fn.size = function() {
342         migrateWarn( "jQuery.fn.size() is deprecated; use the .length property" );
343         return this.length;
344 };
345
346
347 var internalSwapCall = false;
348
349 // If this version of jQuery has .swap(), don't false-alarm on internal uses
350 if ( jQuery.swap ) {
351         jQuery.each( [ "height", "width", "reliableMarginRight" ], function( _, name ) {
352                 var oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;
353
354                 if ( oldHook ) {
355                         jQuery.cssHooks[ name ].get = function() {
356                                 var ret;
357
358                                 internalSwapCall = true;
359                                 ret = oldHook.apply( this, arguments );
360                                 internalSwapCall = false;
361                                 return ret;
362                         };
363                 }
364         });
365 }
366
367 jQuery.swap = function( elem, options, callback, args ) {
368         var ret, name,
369                 old = {};
370
371         if ( !internalSwapCall ) {
372                 migrateWarn( "jQuery.swap() is undocumented and deprecated" );
373         }
374
375         // Remember the old values, and insert the new ones
376         for ( name in options ) {
377                 old[ name ] = elem.style[ name ];
378                 elem.style[ name ] = options[ name ];
379         }
380
381         ret = callback.apply( elem, args || [] );
382
383         // Revert the old values
384         for ( name in options ) {
385                 elem.style[ name ] = old[ name ];
386         }
387
388         return ret;
389 };
390
391
392 // Ensure that $.ajax gets the new parseJSON defined in core.js
393 jQuery.ajaxSetup({
394         converters: {
395                 "text json": jQuery.parseJSON
396         }
397 });
398
399
400 var oldFnData = jQuery.fn.data;
401
402 jQuery.fn.data = function( name ) {
403         var ret, evt,
404                 elem = this[0];
405
406         // Handles 1.7 which has this behavior and 1.8 which doesn't
407         if ( elem && name === "events" && arguments.length === 1 ) {
408                 ret = jQuery.data( elem, name );
409                 evt = jQuery._data( elem, name );
410                 if ( ( ret === undefined || ret === evt ) && evt !== undefined ) {
411                         migrateWarn("Use of jQuery.fn.data('events') is deprecated");
412                         return evt;
413                 }
414         }
415         return oldFnData.apply( this, arguments );
416 };
417
418
419 var rscriptType = /\/(java|ecma)script/i;
420
421 // Since jQuery.clean is used internally on older versions, we only shim if it's missing
422 if ( !jQuery.clean ) {
423         jQuery.clean = function( elems, context, fragment, scripts ) {
424                 // Set context per 1.8 logic
425                 context = context || document;
426                 context = !context.nodeType && context[0] || context;
427                 context = context.ownerDocument || context;
428
429                 migrateWarn("jQuery.clean() is deprecated");
430
431                 var i, elem, handleScript, jsTags,
432                         ret = [];
433
434                 jQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );
435
436                 // Complex logic lifted directly from jQuery 1.8
437                 if ( fragment ) {
438                         // Special handling of each script element
439                         handleScript = function( elem ) {
440                                 // Check if we consider it executable
441                                 if ( !elem.type || rscriptType.test( elem.type ) ) {
442                                         // Detach the script and store it in the scripts array (if provided) or the fragment
443                                         // Return truthy to indicate that it has been handled
444                                         return scripts ?
445                                                 scripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :
446                                                 fragment.appendChild( elem );
447                                 }
448                         };
449
450                         for ( i = 0; (elem = ret[i]) != null; i++ ) {
451                                 // Check if we're done after handling an executable script
452                                 if ( !( jQuery.nodeName( elem, "script" ) && handleScript( elem ) ) ) {
453                                         // Append to fragment and handle embedded scripts
454                                         fragment.appendChild( elem );
455                                         if ( typeof elem.getElementsByTagName !== "undefined" ) {
456                                                 // handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration
457                                                 jsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName("script") ), handleScript );
458
459                                                 // Splice the scripts into ret after their former ancestor and advance our index beyond them
460                                                 ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
461                                                 i += jsTags.length;
462                                         }
463                                 }
464                         }
465                 }
466
467                 return ret;
468         };
469 }
470
471 var eventAdd = jQuery.event.add,
472         eventRemove = jQuery.event.remove,
473         eventTrigger = jQuery.event.trigger,
474         oldToggle = jQuery.fn.toggle,
475         oldLive = jQuery.fn.live,
476         oldDie = jQuery.fn.die,
477         oldLoad = jQuery.fn.load,
478         ajaxEvents = "ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess",
479         rajaxEvent = new RegExp( "\\b(?:" + ajaxEvents + ")\\b" ),
480         rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
481         hoverHack = function( events ) {
482                 if ( typeof( events ) !== "string" || jQuery.event.special.hover ) {
483                         return events;
484                 }
485                 if ( rhoverHack.test( events ) ) {
486                         migrateWarn("'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'");
487                 }
488                 return events && events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
489         };
490
491 // Event props removed in 1.9, put them back if needed; no practical way to warn them
492 if ( jQuery.event.props && jQuery.event.props[ 0 ] !== "attrChange" ) {
493         jQuery.event.props.unshift( "attrChange", "attrName", "relatedNode", "srcElement" );
494 }
495
496 // Undocumented jQuery.event.handle was "deprecated" in jQuery 1.7
497 if ( jQuery.event.dispatch ) {
498         migrateWarnProp( jQuery.event, "handle", jQuery.event.dispatch, "jQuery.event.handle is undocumented and deprecated" );
499 }
500
501 // Support for 'hover' pseudo-event and ajax event warnings
502 jQuery.event.add = function( elem, types, handler, data, selector ){
503         if ( elem !== document && rajaxEvent.test( types ) ) {
504                 migrateWarn( "AJAX events should be attached to document: " + types );
505         }
506         eventAdd.call( this, elem, hoverHack( types || "" ), handler, data, selector );
507 };
508 jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
509         eventRemove.call( this, elem, hoverHack( types ) || "", handler, selector, mappedTypes );
510 };
511
512 jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
513
514         jQuery.fn[ name ] = function() {
515                 var args = Array.prototype.slice.call( arguments, 0 );
516
517                 // If this is an ajax load() the first arg should be the string URL;
518                 // technically this could also be the "Anything" arg of the event .load()
519                 // which just goes to show why this dumb signature has been deprecated!
520                 // jQuery custom builds that exclude the Ajax module justifiably die here.
521                 if ( name === "load" && typeof args[ 0 ] === "string" ) {
522                         return oldLoad.apply( this, args );
523                 }
524
525                 migrateWarn( "jQuery.fn." + name + "() is deprecated" );
526
527                 args.splice( 0, 0, name );
528                 if ( arguments.length ) {
529                         return this.bind.apply( this, args );
530                 }
531
532                 // Use .triggerHandler here because:
533                 // - load and unload events don't need to bubble, only applied to window or image
534                 // - error event should not bubble to window, although it does pre-1.7
535                 // See http://bugs.jquery.com/ticket/11820
536                 this.triggerHandler.apply( this, args );
537                 return this;
538         };
539
540 });
541
542 jQuery.fn.toggle = function( fn, fn2 ) {
543
544         // Don't mess with animation or css toggles
545         if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
546                 return oldToggle.apply( this, arguments );
547         }
548         migrateWarn("jQuery.fn.toggle(handler, handler...) is deprecated");
549
550         // Save reference to arguments for access in closure
551         var args = arguments,
552                 guid = fn.guid || jQuery.guid++,
553                 i = 0,
554                 toggler = function( event ) {
555                         // Figure out which function to execute
556                         var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
557                         jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
558
559                         // Make sure that clicks stop
560                         event.preventDefault();
561
562                         // and execute the function
563                         return args[ lastToggle ].apply( this, arguments ) || false;
564                 };
565
566         // link all the functions, so any of them can unbind this click handler
567         toggler.guid = guid;
568         while ( i < args.length ) {
569                 args[ i++ ].guid = guid;
570         }
571
572         return this.click( toggler );
573 };
574
575 jQuery.fn.live = function( types, data, fn ) {
576         migrateWarn("jQuery.fn.live() is deprecated");
577         if ( oldLive ) {
578                 return oldLive.apply( this, arguments );
579         }
580         jQuery( this.context ).on( types, this.selector, data, fn );
581         return this;
582 };
583
584 jQuery.fn.die = function( types, fn ) {
585         migrateWarn("jQuery.fn.die() is deprecated");
586         if ( oldDie ) {
587                 return oldDie.apply( this, arguments );
588         }
589         jQuery( this.context ).off( types, this.selector || "**", fn );
590         return this;
591 };
592
593 // Turn global events into document-triggered events
594 jQuery.event.trigger = function( event, data, elem, onlyHandlers  ){
595         if ( !elem && !rajaxEvent.test( event ) ) {
596                 migrateWarn( "Global events are undocumented and deprecated" );
597         }
598         return eventTrigger.call( this,  event, data, elem || document, onlyHandlers  );
599 };
600 jQuery.each( ajaxEvents.split("|"),
601         function( _, name ) {
602                 jQuery.event.special[ name ] = {
603                         setup: function() {
604                                 var elem = this;
605
606                                 // The document needs no shimming; must be !== for oldIE
607                                 if ( elem !== document ) {
608                                         jQuery.event.add( document, name + "." + jQuery.guid, function() {
609                                                 jQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );
610                                         });
611                                         jQuery._data( this, name, jQuery.guid++ );
612                                 }
613                                 return false;
614                         },
615                         teardown: function() {
616                                 if ( this !== document ) {
617                                         jQuery.event.remove( document, name + "." + jQuery._data( this, name ) );
618                                 }
619                                 return false;
620                         }
621                 };
622         }
623 );
624
625 jQuery.event.special.ready = {
626         setup: function() {
627                 if ( this === document ) {
628                         migrateWarn( "'ready' event is deprecated" );
629                 }
630         }
631 };
632
633 var oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,
634         oldFind = jQuery.fn.find;
635
636 jQuery.fn.andSelf = function() {
637         migrateWarn("jQuery.fn.andSelf() replaced by jQuery.fn.addBack()");
638         return oldSelf.apply( this, arguments );
639 };
640
641 jQuery.fn.find = function( selector ) {
642         var ret = oldFind.apply( this, arguments );
643         ret.context = this.context;
644         ret.selector = this.selector ? this.selector + " " + selector : selector;
645         return ret;
646 };
647
648
649 // jQuery 1.6 did not support Callbacks, do not warn there
650 if ( jQuery.Callbacks ) {
651
652         var oldDeferred = jQuery.Deferred,
653                 tuples = [
654                         // action, add listener, callbacks, .then handlers, final state
655                         [ "resolve", "done", jQuery.Callbacks("once memory"),
656                                 jQuery.Callbacks("once memory"), "resolved" ],
657                         [ "reject", "fail", jQuery.Callbacks("once memory"),
658                                 jQuery.Callbacks("once memory"), "rejected" ],
659                         [ "notify", "progress", jQuery.Callbacks("memory"),
660                                 jQuery.Callbacks("memory") ]
661                 ];
662
663         jQuery.Deferred = function( func ) {
664                 var deferred = oldDeferred(),
665                         promise = deferred.promise();
666
667                 deferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {
668                         var fns = arguments;
669
670                         migrateWarn( "deferred.pipe() is deprecated" );
671
672                         return jQuery.Deferred(function( newDefer ) {
673                                 jQuery.each( tuples, function( i, tuple ) {
674                                         var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
675                                         // deferred.done(function() { bind to newDefer or newDefer.resolve })
676                                         // deferred.fail(function() { bind to newDefer or newDefer.reject })
677                                         // deferred.progress(function() { bind to newDefer or newDefer.notify })
678                                         deferred[ tuple[1] ](function() {
679                                                 var returned = fn && fn.apply( this, arguments );
680                                                 if ( returned && jQuery.isFunction( returned.promise ) ) {
681                                                         returned.promise()
682                                                                 .done( newDefer.resolve )
683                                                                 .fail( newDefer.reject )
684                                                                 .progress( newDefer.notify );
685                                                 } else {
686                                                         newDefer[ tuple[ 0 ] + "With" ](
687                                                                 this === promise ? newDefer.promise() : this,
688                                                                 fn ? [ returned ] : arguments
689                                                         );
690                                                 }
691                                         });
692                                 });
693                                 fns = null;
694                         }).promise();
695
696                 };
697
698                 deferred.isResolved = function() {
699                         migrateWarn( "deferred.isResolved is deprecated" );
700                         return deferred.state() === "resolved";
701                 };
702
703                 deferred.isRejected = function() {
704                         migrateWarn( "deferred.isRejected is deprecated" );
705                         return deferred.state() === "rejected";
706                 };
707
708                 if ( func ) {
709                         func.call( deferred, deferred );
710                 }
711
712                 return deferred;
713         };
714
715 }
716
717 })( jQuery, window );