mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-12-23 01:24:22 +00:00
9887579b61
Avoid relying on jQuery patches. Instead: * use `CSS.escape` instead of `jQuery.escapeSelector` * use `.filter()` with a proper handler instead of `.even()` Keep `jquery-patch.js` for backwards compatibility, though. Also, add tests for jquery-patch. Ref gh-2249
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
/*!
|
|
* jQuery UI Legacy jQuery Core patches @VERSION
|
|
* https://jqueryui.com
|
|
*
|
|
* Copyright OpenJS Foundation and other contributors
|
|
* Released under the MIT license.
|
|
* https://jquery.org/license
|
|
*
|
|
*/
|
|
|
|
//>>label: Legacy jQuery Core patches
|
|
//>>group: Core
|
|
//>>description: Backport `.even()`, `.odd()` and `$.escapeSelector` to older jQuery Core versions (deprecated)
|
|
|
|
( function( factory ) {
|
|
"use strict";
|
|
|
|
if ( typeof define === "function" && define.amd ) {
|
|
|
|
// AMD. Register as an anonymous module.
|
|
define( [ "jquery", "./version" ], factory );
|
|
} else {
|
|
|
|
// Browser globals
|
|
factory( jQuery );
|
|
}
|
|
} )( function( $ ) {
|
|
"use strict";
|
|
|
|
// Support: jQuery 2.2.x or older.
|
|
// This method has been defined in jQuery 3.0.0.
|
|
// Code from https://github.com/jquery/jquery/blob/e539bac79e666bba95bba86d690b4e609dca2286/src/selector/escapeSelector.js
|
|
if ( !$.escapeSelector ) {
|
|
$.escapeSelector = function( id ) {
|
|
return CSS.escape( id + "" );
|
|
};
|
|
}
|
|
|
|
// Support: jQuery 3.4.x or older
|
|
// These methods have been defined in jQuery 3.5.0.
|
|
if ( !$.fn.even || !$.fn.odd ) {
|
|
$.fn.extend( {
|
|
even: function() {
|
|
return this.filter( function( i ) {
|
|
return i % 2 === 0;
|
|
} );
|
|
},
|
|
odd: function() {
|
|
return this.filter( function( i ) {
|
|
return i % 2 === 1;
|
|
} );
|
|
}
|
|
} );
|
|
}
|
|
|
|
} );
|