deprecated.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // Require that the "whitespace run" starts from a non-whitespace
  16. // to avoid O(N^2) behavior when the engine would try matching "\s+$" at each space position.
  17. var rtrim = /^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;
  18. // Bind a function to a context, optionally partially applying any
  19. // arguments.
  20. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  21. // However, it is not slated for removal any time soon
  22. jQuery.proxy = function( fn, context ) {
  23. var tmp, args, proxy;
  24. if ( typeof context === "string" ) {
  25. tmp = fn[ context ];
  26. context = fn;
  27. fn = tmp;
  28. }
  29. // Quick check to determine if target is callable, in the spec
  30. // this throws a TypeError, but we will just return undefined.
  31. if ( !isFunction( fn ) ) {
  32. return undefined;
  33. }
  34. // Simulated bind
  35. args = slice.call( arguments, 2 );
  36. proxy = function() {
  37. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  38. };
  39. // Set the guid of unique handler to the same of original handler, so it can be removed
  40. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  41. return proxy;
  42. };
  43. jQuery.holdReady = function( hold ) {
  44. if ( hold ) {
  45. jQuery.readyWait++;
  46. } else {
  47. jQuery.ready( true );
  48. }
  49. };
  50. jQuery.isArray = Array.isArray;
  51. jQuery.parseJSON = JSON.parse;
  52. jQuery.nodeName = nodeName;
  53. jQuery.isFunction = isFunction;
  54. jQuery.isWindow = isWindow;
  55. jQuery.camelCase = camelCase;
  56. jQuery.type = toType;
  57. jQuery.now = Date.now;
  58. jQuery.isNumeric = function( obj ) {
  59. // As of jQuery 3.0, isNumeric is limited to
  60. // strings and numbers (primitives or objects)
  61. // that can be coerced to finite numbers (gh-2662)
  62. var type = jQuery.type( obj );
  63. return ( type === "number" || type === "string" ) &&
  64. // parseFloat NaNs numeric-cast false positives ("")
  65. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  66. // subtraction forces infinities to NaN
  67. !isNaN( obj - parseFloat( obj ) );
  68. };
  69. jQuery.trim = function( text ) {
  70. return text == null ?
  71. "" :
  72. ( text + "" ).replace( rtrim, "$1" );
  73. };
  74. } );