aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery-patch.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2021-05-14 23:37:19 +0200
committerGitHub <noreply@github.com>2021-05-14 23:37:19 +0200
commit7c6a9f01281a9739f54ef57d7deecb41a873ef38 (patch)
treeb817231c1c6098c41a44713c5e8f2ad428b18457 /ui/jquery-patch.js
parentafe20b79a64266e64011f34b26a30b3d1c62fd47 (diff)
downloadjquery-ui-7c6a9f01281a9739f54ef57d7deecb41a873ef38.tar.gz
jquery-ui-7c6a9f01281a9739f54ef57d7deecb41a873ef38.zip
All: Drop $.ui.escapeSelector in favor of $.escapeSelector
Fixes #14991 Closes gh-1957
Diffstat (limited to 'ui/jquery-patch.js')
-rw-r--r--ui/jquery-patch.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/jquery-patch.js b/ui/jquery-patch.js
index 4d939535e..578c47a3f 100644
--- a/ui/jquery-patch.js
+++ b/ui/jquery-patch.js
@@ -36,6 +36,36 @@ if ( !$.uniqueSort ) {
$.uniqueSort = $.unique;
}
+// 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 ) {
+
+ // 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 );
+ };
+}
+
// Support: jQuery 3.4.x or older
// These methods have been defined in jQuery 3.5.0.
if ( !$.fn.even || !$.fn.odd ) {