jquery-patch.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*!
  2. * jQuery UI Legacy jQuery Core patches 1.14.1
  3. * https://jqueryui.com
  4. *
  5. * Copyright OpenJS Foundation and other contributors
  6. * Released under the MIT license.
  7. * https://jquery.org/license
  8. *
  9. */
  10. //>>label: Legacy jQuery Core patches
  11. //>>group: Core
  12. //>>description: Backport `.even()`, `.odd()` and `$.escapeSelector` to older jQuery Core versions (deprecated)
  13. ( function( factory ) {
  14. "use strict";
  15. if ( typeof define === "function" && define.amd ) {
  16. // AMD. Register as an anonymous module.
  17. define( [ "jquery", "./version" ], factory );
  18. } else {
  19. // Browser globals
  20. factory( jQuery );
  21. }
  22. } )( function( $ ) {
  23. "use strict";
  24. // Support: jQuery 2.2.x or older.
  25. // This method has been defined in jQuery 3.0.0.
  26. // Code from https://github.com/jquery/jquery/blob/e539bac79e666bba95bba86d690b4e609dca2286/src/selector/escapeSelector.js
  27. if ( !$.escapeSelector ) {
  28. $.escapeSelector = function( id ) {
  29. return CSS.escape( id + "" );
  30. };
  31. }
  32. // Support: jQuery 3.4.x or older
  33. // These methods have been defined in jQuery 3.5.0.
  34. if ( !$.fn.even || !$.fn.odd ) {
  35. $.fn.extend( {
  36. even: function() {
  37. return this.filter( function( i ) {
  38. return i % 2 === 0;
  39. } );
  40. },
  41. odd: function() {
  42. return this.filter( function( i ) {
  43. return i % 2 === 1;
  44. } );
  45. }
  46. } );
  47. }
  48. } );