deprecated.js 2.2 KB

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