Skip to content
Permalink
Browse files

Core: Fix JQMIGRATE warning about `jQuery.expr[":"]`

This commit polyfills `jQuery.expr.pseudos` for old versions of jQuery.

Fixes #15185
Closes gh-1773
  • Loading branch information
eirslett authored and scottgonzalez committed May 2, 2017
1 parent 50efd6e commit 0b7246b6eeadfa9e2696e22f3230f6452f8129dc
Showing with 20 additions and 8 deletions.
  1. +1 −1 ui/data.js
  2. +1 −1 ui/focusable.js
  3. +13 −1 ui/jquery-1-7.js
  4. +1 −1 ui/tabbable.js
  5. +2 −2 ui/widget.js
  6. +1 −1 ui/widgets/controlgroup.js
  7. +1 −1 ui/widgets/tabs.js
@@ -23,7 +23,7 @@
factory( jQuery );
}
} ( function( $ ) {
return $.extend( $.expr[ ":" ], {
return $.extend( $.expr.pseudos, {
data: $.expr.createPseudo ?
$.expr.createPseudo( function( dataName ) {
return function( elem ) {
@@ -73,7 +73,7 @@ function visible( element ) {
return visibility !== "hidden";
}

$.extend( $.expr[ ":" ], {
$.extend( $.expr.pseudos, {
focusable: function( element ) {
return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
}
@@ -1,5 +1,5 @@
/*!
* jQuery UI Support for jQuery core 1.7.x @VERSION
* jQuery UI Support for jQuery core 1.7.x and newer @VERSION
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -86,4 +86,16 @@ if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
};
}

// Support: jQuery 1.9.x or older
// $.expr[ ":" ] is deprecated.
if ( !$.expr.pseudos ) {
$.expr.pseudos = $.expr[ ":" ];
}

// Support: jQuery 1.11.x or older
// $.unique has been renamed to $.uniqueSort
if ( !$.uniqueSort ) {
$.uniqueSort = $.unique;
}

} ) );
@@ -24,7 +24,7 @@
}
} ( function( $ ) {

return $.extend( $.expr[ ":" ], {
return $.extend( $.expr.pseudos, {
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
hasTabindex = tabIndex != null;
@@ -65,7 +65,7 @@ $.widget = function( name, base, prototype ) {
}

// Create selector for plugin
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
$.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
return !!$.data( elem, fullName );
};

@@ -517,7 +517,7 @@ $.Widget.prototype = {
current = that.classesElementLookup[ classes[ i ] ] || $();
if ( options.add ) {
bindRemoveEvent();
current = $( $.unique( current.get().concat( options.element.get() ) ) );
current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
} else {
current = $( current.not( options.element ).get() );
}
@@ -150,7 +150,7 @@ return $.widget( "ui.controlgroup", {
} );
} );

this.childWidgets = $( $.unique( childWidgets ) );
this.childWidgets = $( $.uniqueSort( childWidgets ) );
this._addClass( this.childWidgets, "ui-controlgroup-item" );
},

@@ -96,7 +96,7 @@ $.widget( "ui.tabs", {
// Take disabling tabs via class attribute from HTML
// into account and update option properly.
if ( $.isArray( options.disabled ) ) {
options.disabled = $.unique( options.disabled.concat(
options.disabled = $.uniqueSort( options.disabled.concat(
$.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
return that.tabs.index( li );
} )

0 comments on commit 0b7246b

Please sign in to comment.
You can’t perform that action at this time.