diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2024-05-10 14:45:59 +0200 |
---|---|---|
committer | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2024-05-15 00:38:40 +0200 |
commit | 9887579b61972647f1478e64c5d7987f9d9cb039 (patch) | |
tree | c592a65dd9a8f9a6a7a3a31892eec299e1799a80 /ui/jquery-patch.js | |
parent | f90eab84b5e9a65ce62f18106e3db0ee316913f6 (diff) | |
download | jquery-ui-9887579b61972647f1478e64c5d7987f9d9cb039.tar.gz jquery-ui-9887579b61972647f1478e64c5d7987f9d9cb039.zip |
All: Stop relying on jquery-patch.js internally, add tests
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
Diffstat (limited to 'ui/jquery-patch.js')
-rw-r--r-- | ui/jquery-patch.js | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/ui/jquery-patch.js b/ui/jquery-patch.js index e03b32edf..a4001048d 100644 --- a/ui/jquery-patch.js +++ b/ui/jquery-patch.js @@ -1,5 +1,5 @@ /*! - * jQuery UI Support for jQuery core 1.8.x and newer @VERSION + * jQuery UI Legacy jQuery Core patches @VERSION * https://jqueryui.com * * Copyright OpenJS Foundation and other contributors @@ -8,9 +8,9 @@ * */ -//>>label: jQuery 1.8+ Support +//>>label: Legacy jQuery Core patches //>>group: Core -//>>description: Support version 1.8.x and newer of jQuery core +//>>description: Backport `.even()`, `.odd()` and `$.escapeSelector` to older jQuery Core versions (deprecated) ( function( factory ) { "use strict"; @@ -31,29 +31,8 @@ // 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 ) { - - // CSS string/identifier serialization - // https://drafts.csswg.org/cssom/#common-serializing-idioms - var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g; - - var fcssescape = function( ch, asCodePoint ) { - if ( asCodePoint ) { - - // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER - if ( ch === "\0" ) { - return "\uFFFD"; - } - - // Control characters and (dependent upon position) numbers get escaped as code points - return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; - } - - // Other potentially-special ASCII characters get backslash-escaped - return "\\" + ch; - }; - - $.escapeSelector = function( sel ) { - return ( sel + "" ).replace( rcssescape, fcssescape ); + $.escapeSelector = function( id ) { + return CSS.escape( id + "" ); }; } |