Skip to content

Commit 0b7246b

Browse files
eirslettscottgonzalez
authored andcommitted
Core: Fix JQMIGRATE warning about jQuery.expr[":"]
This commit polyfills `jQuery.expr.pseudos` for old versions of jQuery. Fixes #15185 Closes jquerygh-1773
1 parent 50efd6e commit 0b7246b

File tree

7 files changed

+20
-8
lines changed

7 files changed

+20
-8
lines changed

ui/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
factory( jQuery );
2424
}
2525
} ( function( $ ) {
26-
return $.extend( $.expr[ ":" ], {
26+
return $.extend( $.expr.pseudos, {
2727
data: $.expr.createPseudo ?
2828
$.expr.createPseudo( function( dataName ) {
2929
return function( elem ) {

ui/focusable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function visible( element ) {
7373
return visibility !== "hidden";
7474
}
7575

76-
$.extend( $.expr[ ":" ], {
76+
$.extend( $.expr.pseudos, {
7777
focusable: function( element ) {
7878
return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
7979
}

ui/jquery-1-7.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery UI Support for jQuery core 1.7.x @VERSION
2+
* jQuery UI Support for jQuery core 1.7.x and newer @VERSION
33
* http://jqueryui.com
44
*
55
* Copyright jQuery Foundation and other contributors
@@ -86,4 +86,16 @@ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
8686
};
8787
}
8888

89+
// Support: jQuery 1.9.x or older
90+
// $.expr[ ":" ] is deprecated.
91+
if ( !$.expr.pseudos ) {
92+
$.expr.pseudos = $.expr[ ":" ];
93+
}
94+
95+
// Support: jQuery 1.11.x or older
96+
// $.unique has been renamed to $.uniqueSort
97+
if ( !$.uniqueSort ) {
98+
$.uniqueSort = $.unique;
99+
}
100+
89101
} ) );

ui/tabbable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525
} ( function( $ ) {
2626

27-
return $.extend( $.expr[ ":" ], {
27+
return $.extend( $.expr.pseudos, {
2828
tabbable: function( element ) {
2929
var tabIndex = $.attr( element, "tabindex" ),
3030
hasTabindex = tabIndex != null;

ui/widget.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ $.widget = function( name, base, prototype ) {
6565
}
6666

6767
// Create selector for plugin
68-
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
68+
$.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
6969
return !!$.data( elem, fullName );
7070
};
7171

@@ -517,7 +517,7 @@ $.Widget.prototype = {
517517
current = that.classesElementLookup[ classes[ i ] ] || $();
518518
if ( options.add ) {
519519
bindRemoveEvent();
520-
current = $( $.unique( current.get().concat( options.element.get() ) ) );
520+
current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
521521
} else {
522522
current = $( current.not( options.element ).get() );
523523
}

ui/widgets/controlgroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ return $.widget( "ui.controlgroup", {
150150
} );
151151
} );
152152

153-
this.childWidgets = $( $.unique( childWidgets ) );
153+
this.childWidgets = $( $.uniqueSort( childWidgets ) );
154154
this._addClass( this.childWidgets, "ui-controlgroup-item" );
155155
},
156156

ui/widgets/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $.widget( "ui.tabs", {
9696
// Take disabling tabs via class attribute from HTML
9797
// into account and update option properly.
9898
if ( $.isArray( options.disabled ) ) {
99-
options.disabled = $.unique( options.disabled.concat(
99+
options.disabled = $.uniqueSort( options.disabled.concat(
100100
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
101101
return that.tabs.index( li );
102102
} )

0 commit comments

Comments
 (0)