aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Sletteberg <eiriksletteberg@gmail.com>2016-12-02 14:41:30 +0100
committerScott González <scott.gonzalez@gmail.com>2017-05-02 15:28:51 -0400
commit0b7246b6eeadfa9e2696e22f3230f6452f8129dc (patch)
tree02cd4f06e3944fc1417d4687cb3d14a12f3e8683
parent50efd6e1b063822c4a0ecb38f324ed3354f387c4 (diff)
downloadjquery-ui-0b7246b6eeadfa9e2696e22f3230f6452f8129dc.tar.gz
jquery-ui-0b7246b6eeadfa9e2696e22f3230f6452f8129dc.zip
Core: Fix JQMIGRATE warning about `jQuery.expr[":"]`
This commit polyfills `jQuery.expr.pseudos` for old versions of jQuery. Fixes #15185 Closes gh-1773
-rw-r--r--ui/data.js2
-rw-r--r--ui/focusable.js2
-rw-r--r--ui/jquery-1-7.js14
-rw-r--r--ui/tabbable.js2
-rw-r--r--ui/widget.js4
-rw-r--r--ui/widgets/controlgroup.js2
-rw-r--r--ui/widgets/tabs.js2
7 files changed, 20 insertions, 8 deletions
diff --git a/ui/data.js b/ui/data.js
index d0417b8f9..c02e7ffde 100644
--- a/ui/data.js
+++ b/ui/data.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 ) {
diff --git a/ui/focusable.js b/ui/focusable.js
index cf4f728b8..b1a7b61e2 100644
--- a/ui/focusable.js
+++ b/ui/focusable.js
@@ -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 );
}
diff --git a/ui/jquery-1-7.js b/ui/jquery-1-7.js
index bd40e332f..5e7907a15 100644
--- a/ui/jquery-1-7.js
+++ b/ui/jquery-1-7.js
@@ -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;
+}
+
} ) );
diff --git a/ui/tabbable.js b/ui/tabbable.js
index 3baa641ce..bb79466e8 100644
--- a/ui/tabbable.js
+++ b/ui/tabbable.js
@@ -24,7 +24,7 @@
}
} ( function( $ ) {
-return $.extend( $.expr[ ":" ], {
+return $.extend( $.expr.pseudos, {
tabbable: function( element ) {
var tabIndex = $.attr( element, "tabindex" ),
hasTabindex = tabIndex != null;
diff --git a/ui/widget.js b/ui/widget.js
index 011396811..c101e59d4 100644
--- a/ui/widget.js
+++ b/ui/widget.js
@@ -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() );
}
diff --git a/ui/widgets/controlgroup.js b/ui/widgets/controlgroup.js
index 6f357948d..c79f3fcaf 100644
--- a/ui/widgets/controlgroup.js
+++ b/ui/widgets/controlgroup.js
@@ -150,7 +150,7 @@ return $.widget( "ui.controlgroup", {
} );
} );
- this.childWidgets = $( $.unique( childWidgets ) );
+ this.childWidgets = $( $.uniqueSort( childWidgets ) );
this._addClass( this.childWidgets, "ui-controlgroup-item" );
},
diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js
index 58a65ebe8..14f94ae83 100644
--- a/ui/widgets/tabs.js
+++ b/ui/widgets/tabs.js
@@ -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 );
} )