Event: Make trigger(focus/blur/click) work with native handlers
[jquery.git] / src / deprecated.js
blobe58156f9ecc79fd72eb180d253baf6bad7aaea1f
1 import jQuery from "./core.js";
2 import slice from "./var/slice.js";
4 import "./deprecated/ajax-event-alias.js";
5 import "./deprecated/event.js";
7 // Bind a function to a context, optionally partially applying any
8 // arguments.
9 // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
10 // However, it is not slated for removal any time soon
11 jQuery.proxy = function( fn, context ) {
12         var tmp, args, proxy;
14         if ( typeof context === "string" ) {
15                 tmp = fn[ context ];
16                 context = fn;
17                 fn = tmp;
18         }
20         // Quick check to determine if target is callable, in the spec
21         // this throws a TypeError, but we will just return undefined.
22         if ( typeof fn !== "function" ) {
23                 return undefined;
24         }
26         // Simulated bind
27         args = slice.call( arguments, 2 );
28         proxy = function() {
29                 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
30         };
32         // Set the guid of unique handler to the same of original handler, so it can be removed
33         proxy.guid = fn.guid = fn.guid || jQuery.guid++;
35         return proxy;
38 jQuery.holdReady = function( hold ) {
39         if ( hold ) {
40                 jQuery.readyWait++;
41         } else {
42                 jQuery.ready( true );
43         }