From 9887579b61972647f1478e64c5d7987f9d9cb039 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski-Owczarek Date: Fri, 10 May 2024 14:45:59 +0200 Subject: 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 --- ui/widgets/accordion.js | 12 +++++++++++- ui/widgets/checkboxradio.js | 2 +- ui/widgets/selectmenu.js | 2 +- ui/widgets/tabs.js | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'ui/widgets') diff --git a/ui/widgets/accordion.js b/ui/widgets/accordion.js index b6a7a7eee..ff6e4631d 100644 --- a/ui/widgets/accordion.js +++ b/ui/widgets/accordion.js @@ -52,7 +52,17 @@ return $.widget( "ui.accordion", { collapsible: false, event: "click", header: function( elem ) { - return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() ); + return elem + .find( "> li > :first-child" ) + .add( + elem.find( "> :not(li)" ) + + // Support: jQuery <3.5 only + // We could use `.even()` but that's unavailable in older jQuery. + .filter( function( i ) { + return i % 2 === 0; + } ) + ); }, heightStyle: "auto", icons: { diff --git a/ui/widgets/checkboxradio.js b/ui/widgets/checkboxradio.js index fc812116e..379252758 100644 --- a/ui/widgets/checkboxradio.js +++ b/ui/widgets/checkboxradio.js @@ -156,7 +156,7 @@ $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { _getRadioGroup: function() { var group; var name = this.element[ 0 ].name; - var nameSelector = "input[name='" + $.escapeSelector( name ) + "']"; + var nameSelector = "input[name='" + CSS.escape( name ) + "']"; if ( !name ) { return $( [] ); diff --git a/ui/widgets/selectmenu.js b/ui/widgets/selectmenu.js index eecd368f5..f1b48fa60 100644 --- a/ui/widgets/selectmenu.js +++ b/ui/widgets/selectmenu.js @@ -415,7 +415,7 @@ return $.widget( "ui.selectmenu", [ $.ui.formResetMixin, { } if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" + - $.escapeSelector( this.ids.button ) ).length ) { + CSS.escape( this.ids.button ) ).length ) { this.close( event ); } } diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js index e191dfbb4..72b868e4f 100644 --- a/ui/widgets/tabs.js +++ b/ui/widgets/tabs.js @@ -722,7 +722,7 @@ $.widget( "ui.tabs", { // meta-function to give users option to provide a href string instead of a numerical index. if ( typeof index === "string" ) { index = this.anchors.index( this.anchors.filter( "[href$='" + - $.escapeSelector( index ) + "']" ) ); + CSS.escape( index ) + "']" ) ); } return index; -- cgit v1.2.3