Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 1 | define( [ |
| 2 | "./core", |
| 3 | "./core/nodeName", |
| 4 | "./core/camelCase", |
| 5 | "./core/toType", |
| 6 | "./var/isFunction", |
| 7 | "./var/isWindow", |
| 8 | "./var/slice", |
| 9 | |
Renovate bot | f591dcf | 2023-12-30 14:13:54 +0000 | [diff] [blame] | 10 | "./deprecated/ajax-event-alias", |
| 11 | "./deprecated/event" |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 12 | ], function( jQuery, nodeName, camelCase, toType, isFunction, isWindow, slice ) { |
| 13 | |
| 14 | "use strict"; |
| 15 | |
Renovate bot | f591dcf | 2023-12-30 14:13:54 +0000 | [diff] [blame] | 16 | // Support: Android <=4.0 only |
| 17 | // Make sure we trim BOM and NBSP |
| 18 | var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 19 | |
| 20 | // Bind a function to a context, optionally partially applying any |
| 21 | // arguments. |
| 22 | // jQuery.proxy is deprecated to promote standards (specifically Function#bind) |
| 23 | // However, it is not slated for removal any time soon |
| 24 | jQuery.proxy = function( fn, context ) { |
| 25 | var tmp, args, proxy; |
| 26 | |
| 27 | if ( typeof context === "string" ) { |
| 28 | tmp = fn[ context ]; |
| 29 | context = fn; |
| 30 | fn = tmp; |
| 31 | } |
| 32 | |
| 33 | // Quick check to determine if target is callable, in the spec |
| 34 | // this throws a TypeError, but we will just return undefined. |
| 35 | if ( !isFunction( fn ) ) { |
| 36 | return undefined; |
| 37 | } |
| 38 | |
| 39 | // Simulated bind |
| 40 | args = slice.call( arguments, 2 ); |
| 41 | proxy = function() { |
| 42 | return fn.apply( context || this, args.concat( slice.call( arguments ) ) ); |
| 43 | }; |
| 44 | |
| 45 | // Set the guid of unique handler to the same of original handler, so it can be removed |
| 46 | proxy.guid = fn.guid = fn.guid || jQuery.guid++; |
| 47 | |
| 48 | return proxy; |
| 49 | }; |
| 50 | |
| 51 | jQuery.holdReady = function( hold ) { |
| 52 | if ( hold ) { |
| 53 | jQuery.readyWait++; |
| 54 | } else { |
| 55 | jQuery.ready( true ); |
| 56 | } |
| 57 | }; |
| 58 | jQuery.isArray = Array.isArray; |
| 59 | jQuery.parseJSON = JSON.parse; |
| 60 | jQuery.nodeName = nodeName; |
| 61 | jQuery.isFunction = isFunction; |
| 62 | jQuery.isWindow = isWindow; |
| 63 | jQuery.camelCase = camelCase; |
| 64 | jQuery.type = toType; |
| 65 | |
| 66 | jQuery.now = Date.now; |
| 67 | |
| 68 | jQuery.isNumeric = function( obj ) { |
| 69 | |
| 70 | // As of jQuery 3.0, isNumeric is limited to |
| 71 | // strings and numbers (primitives or objects) |
| 72 | // that can be coerced to finite numbers (gh-2662) |
| 73 | var type = jQuery.type( obj ); |
| 74 | return ( type === "number" || type === "string" ) && |
| 75 | |
| 76 | // parseFloat NaNs numeric-cast false positives ("") |
| 77 | // ...but misinterprets leading-number strings, particularly hex literals ("0x...") |
| 78 | // subtraction forces infinities to NaN |
| 79 | !isNaN( obj - parseFloat( obj ) ); |
| 80 | }; |
| 81 | |
Renovate bot | f591dcf | 2023-12-30 14:13:54 +0000 | [diff] [blame] | 82 | jQuery.trim = function( text ) { |
| 83 | return text == null ? |
| 84 | "" : |
| 85 | ( text + "" ).replace( rtrim, "" ); |
| 86 | }; |
Copybara bot | be50d49 | 2023-11-30 00:16:42 +0100 | [diff] [blame] | 87 | } ); |