mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
All: Drop $.ui.escapeSelector in favor of $.escapeSelector
Fixes #14991 Closes gh-1957
This commit is contained in:
parent
afe20b79a6
commit
7c6a9f0128
@ -3,7 +3,6 @@ define( [
|
|||||||
"jquery",
|
"jquery",
|
||||||
"lib/helper",
|
"lib/helper",
|
||||||
"ui/data",
|
"ui/data",
|
||||||
"ui/escape-selector",
|
|
||||||
"ui/focusable",
|
"ui/focusable",
|
||||||
"ui/tabbable"
|
"ui/tabbable"
|
||||||
], function( QUnit, $, helper ) {
|
], function( QUnit, $, helper ) {
|
||||||
@ -280,11 +279,4 @@ QUnit.test( "tabbable - dimensionless parent with overflow", function( assert )
|
|||||||
assert.isTabbable( "#dimensionlessParent", "input" );
|
assert.isTabbable( "#dimensionlessParent", "input" );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "escapeSelector", function( assert ) {
|
|
||||||
assert.expect( 1 );
|
|
||||||
|
|
||||||
assert.equal( $( "#" + $.ui.escapeSelector( "weird-['x']-id" ) ).length, 1,
|
|
||||||
"properly escapes selectors to use as an id" );
|
|
||||||
} );
|
|
||||||
|
|
||||||
} );
|
} );
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
( function( factory ) {
|
|
||||||
if ( typeof define === "function" && define.amd ) {
|
|
||||||
|
|
||||||
// AMD. Register as an anonymous module.
|
|
||||||
define( [ "jquery", "./version" ], factory );
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// Browser globals
|
|
||||||
factory( jQuery );
|
|
||||||
}
|
|
||||||
} ( function( $ ) {
|
|
||||||
|
|
||||||
// Internal use only
|
|
||||||
return $.ui.escapeSelector = ( function() {
|
|
||||||
var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
|
|
||||||
return function( selector ) {
|
|
||||||
return selector.replace( selectorEscape, "\\$1" );
|
|
||||||
};
|
|
||||||
} )();
|
|
||||||
|
|
||||||
} ) );
|
|
30
ui/jquery-patch.js
vendored
30
ui/jquery-patch.js
vendored
@ -36,6 +36,36 @@ if ( !$.uniqueSort ) {
|
|||||||
$.uniqueSort = $.unique;
|
$.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
|
// Support: jQuery 3.4.x or older
|
||||||
// These methods have been defined in jQuery 3.5.0.
|
// These methods have been defined in jQuery 3.5.0.
|
||||||
if ( !$.fn.even || !$.fn.odd ) {
|
if ( !$.fn.even || !$.fn.odd ) {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
if ( typeof define === "function" && define.amd ) {
|
if ( typeof define === "function" && define.amd ) {
|
||||||
|
|
||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define( [ "jquery", "./version", "./escape-selector" ], factory );
|
define( [ "jquery", "./version" ], factory );
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Browser globals
|
// Browser globals
|
||||||
@ -53,7 +53,7 @@ return $.fn.labels = function() {
|
|||||||
ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
|
ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
|
||||||
|
|
||||||
// Create a selector for the label based on the id
|
// Create a selector for the label based on the id
|
||||||
selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
|
selector = "label[for='" + $.escapeSelector( id ) + "']";
|
||||||
|
|
||||||
labels = labels.add( ancestors.find( selector ).addBack( selector ) );
|
labels = labels.add( ancestors.find( selector ).addBack( selector ) );
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define( [
|
define( [
|
||||||
"jquery",
|
"jquery",
|
||||||
"../escape-selector",
|
|
||||||
"../form-reset-mixin",
|
"../form-reset-mixin",
|
||||||
"../labels",
|
"../labels",
|
||||||
"../widget"
|
"../widget"
|
||||||
@ -149,7 +148,7 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
|
|||||||
_getRadioGroup: function() {
|
_getRadioGroup: function() {
|
||||||
var group;
|
var group;
|
||||||
var name = this.element[ 0 ].name;
|
var name = this.element[ 0 ].name;
|
||||||
var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
|
var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
|
||||||
|
|
||||||
if ( !name ) {
|
if ( !name ) {
|
||||||
return $( [] );
|
return $( [] );
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
define( [
|
define( [
|
||||||
"jquery",
|
"jquery",
|
||||||
"./menu",
|
"./menu",
|
||||||
"../escape-selector",
|
|
||||||
"../form-reset-mixin",
|
"../form-reset-mixin",
|
||||||
"../keycode",
|
"../keycode",
|
||||||
"../labels",
|
"../labels",
|
||||||
@ -425,7 +424,7 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
|
if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
|
||||||
$.ui.escapeSelector( this.ids.button ) ).length ) {
|
$.escapeSelector( this.ids.button ) ).length ) {
|
||||||
this.close( event );
|
this.close( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
// AMD. Register as an anonymous module.
|
// AMD. Register as an anonymous module.
|
||||||
define( [
|
define( [
|
||||||
"jquery",
|
"jquery",
|
||||||
"../escape-selector",
|
|
||||||
"../keycode",
|
"../keycode",
|
||||||
"../safe-active-element",
|
"../safe-active-element",
|
||||||
"../unique-id",
|
"../unique-id",
|
||||||
@ -733,7 +732,7 @@ $.widget( "ui.tabs", {
|
|||||||
// meta-function to give users option to provide a href string instead of a numerical index.
|
// meta-function to give users option to provide a href string instead of a numerical index.
|
||||||
if ( typeof index === "string" ) {
|
if ( typeof index === "string" ) {
|
||||||
index = this.anchors.index( this.anchors.filter( "[href$='" +
|
index = this.anchors.index( this.anchors.filter( "[href$='" +
|
||||||
$.ui.escapeSelector( index ) + "']" ) );
|
$.escapeSelector( index ) + "']" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
|
Loading…
Reference in New Issue
Block a user