diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-12-08 22:23:08 +0100 |
---|---|---|
committer | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2019-12-08 22:23:08 +0100 |
commit | 98b539171b6e805fa79346a5e9896865e5213b9c (patch) | |
tree | f6c296195f081c538f90c96f43f28012670960a5 /ui/widgets | |
parent | 74f8a0ac952f6f45f773312292baef1c26d81300 (diff) | |
download | jquery-ui-98b539171b6e805fa79346a5e9896865e5213b9c.tar.gz jquery-ui-98b539171b6e805fa79346a5e9896865e5213b9c.zip |
All: Migrate away from deprecated/removed Core APIs
Summary of the changes:
* Build: Add jQuery 3.2.0-3.4.1 to versions UI can be tested against
* Build: Load jQuery & Migrate via HTTPS
* Build: Add package-lock.json to .gitignore
* Build: Update jQuery Migrate from 3.0.0 to 3.1.0
* Build: Allow to run tests against jQuery 3.x-git
* Build: Fix formatting according to JSCS rules
* Build: Disable JSCS for the inlined jQuery Color
* All: Switch from $.isArray to Array.isArray (jQuery.isArray will be
removed in jQuery 4.0)
* All: Switch from `$.isFunction( x )` to `typeof x === "function"`
(jQuery.isFunction will be removed in jQuery 4.0)
* All: Inline jQuery.isWindow as it'll be removed in jQuery 4.0
* Effects: Fix a timing issue in a variable declaration. Previously,
a jQuery object was created, chained & assigned to a variable that
was then accessed in a callback used inside of this chained
definition. Due to a timing difference in when the callback fired for
the first time in latest jQuery master, it was being called before
the variable was defined.
* Tests: Make dialog & draggable unit tests less strict (newest jQuery
returns fractional results in some cases, making comparisons fail when
there's a tiny difference)
* All: Migrate from $.trim to bare String.prototype.trim (jQuery.trim
will be deprecated in jQuery 3.5)
Closes gh-1901
Diffstat (limited to 'ui/widgets')
-rw-r--r-- | ui/widgets/autocomplete.js | 4 | ||||
-rw-r--r-- | ui/widgets/button.js | 3 | ||||
-rw-r--r-- | ui/widgets/controlgroup.js | 2 | ||||
-rw-r--r-- | ui/widgets/dialog.js | 4 | ||||
-rw-r--r-- | ui/widgets/draggable.js | 6 | ||||
-rw-r--r-- | ui/widgets/droppable.js | 4 | ||||
-rw-r--r-- | ui/widgets/menu.js | 3 | ||||
-rw-r--r-- | ui/widgets/resizable.js | 2 | ||||
-rw-r--r-- | ui/widgets/slider.js | 6 | ||||
-rw-r--r-- | ui/widgets/sortable.js | 12 | ||||
-rw-r--r-- | ui/widgets/spinner.js | 2 | ||||
-rw-r--r-- | ui/widgets/tabs.js | 8 | ||||
-rw-r--r-- | ui/widgets/tooltip.js | 4 |
13 files changed, 31 insertions, 29 deletions
diff --git a/ui/widgets/autocomplete.js b/ui/widgets/autocomplete.js index 60d326544..66756820b 100644 --- a/ui/widgets/autocomplete.js +++ b/ui/widgets/autocomplete.js @@ -263,7 +263,7 @@ $.widget( "ui.autocomplete", { // Announce the value in the liveRegion label = ui.item.attr( "aria-label" ) || item.value; - if ( label && $.trim( label ).length ) { + if ( label && String.prototype.trim.call( label ).length ) { this.liveRegion.children().hide(); $( "<div>" ).text( label ).appendTo( this.liveRegion ); } @@ -375,7 +375,7 @@ $.widget( "ui.autocomplete", { _initSource: function() { var array, url, that = this; - if ( $.isArray( this.options.source ) ) { + if ( Array.isArray( this.options.source ) ) { array = this.options.source; this.source = function( request, response ) { response( $.ui.autocomplete.filter( array, request.term ) ); diff --git a/ui/widgets/button.js b/ui/widgets/button.js index 42cfec06d..3def0f9aa 100644 --- a/ui/widgets/button.js +++ b/ui/widgets/button.js @@ -373,7 +373,8 @@ if ( $.uiBackCompat !== false ) { "attempted to call method '" + options + "'" ); } - if ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) { + if ( typeof instance[ options ] !== "function" || + options.charAt( 0 ) === "_" ) { return $.error( "no such method '" + options + "' for button" + " widget instance" ); } diff --git a/ui/widgets/controlgroup.js b/ui/widgets/controlgroup.js index c79f3fcaf..019abbec9 100644 --- a/ui/widgets/controlgroup.js +++ b/ui/widgets/controlgroup.js @@ -234,7 +234,7 @@ return $.widget( "ui.controlgroup", { var result = {}; $.each( classes, function( key ) { var current = instance.options.classes[ key ] || ""; - current = $.trim( current.replace( controlgroupCornerRegex, "" ) ); + current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) ); result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " ); } ); return result; diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js index 01780daf3..e4798e0d7 100644 --- a/ui/widgets/dialog.js +++ b/ui/widgets/dialog.js @@ -481,14 +481,14 @@ $.widget( "ui.dialog", { this.uiDialogButtonPane.remove(); this.uiButtonSet.empty(); - if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) { + if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) { this._removeClass( this.uiDialog, "ui-dialog-buttons" ); return; } $.each( buttons, function( name, props ) { var click, buttonOptions; - props = $.isFunction( props ) ? + props = typeof props === "function" ? { click: props, text: name } : props; diff --git a/ui/widgets/draggable.js b/ui/widgets/draggable.js index 9e46c81bb..5f41d2408 100644 --- a/ui/widgets/draggable.js +++ b/ui/widgets/draggable.js @@ -296,7 +296,7 @@ $.widget( "ui.draggable", $.ui.mouse, { if ( ( this.options.revert === "invalid" && !dropped ) || ( this.options.revert === "valid" && dropped ) || - this.options.revert === true || ( $.isFunction( this.options.revert ) && + this.options.revert === true || ( typeof this.options.revert === "function" && this.options.revert.call( this.element, dropped ) ) ) { $( this.helper ).animate( @@ -368,7 +368,7 @@ $.widget( "ui.draggable", $.ui.mouse, { _createHelper: function( event ) { var o = this.options, - helperIsFunction = $.isFunction( o.helper ), + helperIsFunction = typeof o.helper === "function", helper = helperIsFunction ? $( o.helper.apply( this.element[ 0 ], [ event ] ) ) : ( o.helper === "clone" ? @@ -407,7 +407,7 @@ $.widget( "ui.draggable", $.ui.mouse, { if ( typeof obj === "string" ) { obj = obj.split( " " ); } - if ( $.isArray( obj ) ) { + if ( Array.isArray( obj ) ) { obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; } if ( "left" in obj ) { diff --git a/ui/widgets/droppable.js b/ui/widgets/droppable.js index 89bff2511..f98ff2714 100644 --- a/ui/widgets/droppable.js +++ b/ui/widgets/droppable.js @@ -57,7 +57,7 @@ $.widget( "ui.droppable", { this.isover = false; this.isout = true; - this.accept = $.isFunction( accept ) ? accept : function( d ) { + this.accept = typeof accept === "function" ? accept : function( d ) { return d.is( accept ); }; @@ -109,7 +109,7 @@ $.widget( "ui.droppable", { _setOption: function( key, value ) { if ( key === "accept" ) { - this.accept = $.isFunction( value ) ? value : function( d ) { + this.accept = typeof value === "function" ? value : function( d ) { return d.is( value ); }; } else if ( key === "scope" ) { diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 302d202ae..7706ee578 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -689,7 +689,8 @@ return $.widget( "ui.menu", { .filter( ".ui-menu-item" ) .filter( function() { return regex.test( - $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) ); + String.prototype.trim.call( + $( this ).children( ".ui-menu-item-wrapper" ).text() ) ); } ); } } ); diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js index 36dd12514..cb0b1b11d 100644 --- a/ui/widgets/resizable.js +++ b/ui/widgets/resizable.js @@ -261,7 +261,7 @@ $.widget( "ui.resizable", $.ui.mouse, { for ( i = 0; i < n.length; i++ ) { - handle = $.trim( n[ i ] ); + handle = String.prototype.trim.call( n[ i ] ); hname = "ui-resizable-" + handle; axis = $( "<div>" ); this._addClass( axis, "ui-resizable-handle " + hname ); diff --git a/ui/widgets/slider.js b/ui/widgets/slider.js index 8b0f907f5..e5004573a 100644 --- a/ui/widgets/slider.js +++ b/ui/widgets/slider.js @@ -132,7 +132,7 @@ return $.widget( "ui.slider", $.ui.mouse, { options.values = [ this._valueMin(), this._valueMin() ]; } else if ( options.values.length && options.values.length !== 2 ) { options.values = [ options.values[ 0 ], options.values[ 0 ] ]; - } else if ( $.isArray( options.values ) ) { + } else if ( Array.isArray( options.values ) ) { options.values = options.values.slice( 0 ); } } @@ -395,7 +395,7 @@ return $.widget( "ui.slider", $.ui.mouse, { } if ( arguments.length ) { - if ( $.isArray( arguments[ 0 ] ) ) { + if ( Array.isArray( arguments[ 0 ] ) ) { vals = this.options.values; newValues = arguments[ 0 ]; for ( i = 0; i < vals.length; i += 1 ) { @@ -429,7 +429,7 @@ return $.widget( "ui.slider", $.ui.mouse, { } } - if ( $.isArray( this.options.values ) ) { + if ( Array.isArray( this.options.values ) ) { valsLength = this.options.values.length; } diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index 78fad26b9..b7daf00bf 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -756,7 +756,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { for ( j = cur.length - 1; j >= 0; j-- ) { inst = $.data( cur[ j ], this.widgetFullName ); if ( inst && inst !== this && !inst.options.disabled ) { - queries.push( [ $.isFunction( inst.options.items ) ? + queries.push( [ typeof inst.options.items === "function" ? inst.options.items.call( inst.element ) : $( inst.options.items, inst.element ) .not( ".ui-sortable-helper" ) @@ -766,7 +766,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { } } - queries.push( [ $.isFunction( this.options.items ) ? + queries.push( [ typeof this.options.items === "function" ? this.options.items .call( this.element, null, { options: this.options, item: this.currentItem } ) : $( this.options.items, this.element ) @@ -806,7 +806,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { var i, j, cur, inst, targetData, _queries, item, queriesLength, items = this.items, - queries = [ [ $.isFunction( this.options.items ) ? + queries = [ [ typeof this.options.items === "function" ? this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) : $( this.options.items, this.element ), this ] ], connectWith = this._connectWith(); @@ -818,7 +818,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { for ( j = cur.length - 1; j >= 0; j-- ) { inst = $.data( cur[ j ], this.widgetFullName ); if ( inst && inst !== this && !inst.options.disabled ) { - queries.push( [ $.isFunction( inst.options.items ) ? + queries.push( [ typeof inst.options.items === "function" ? inst.options.items .call( inst.element[ 0 ], event, { item: this.currentItem } ) : $( inst.options.items, inst.element ), inst ] ); @@ -1121,7 +1121,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { _createHelper: function( event ) { var o = this.options, - helper = $.isFunction( o.helper ) ? + helper = typeof o.helper === "function" ? $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) : ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem ); @@ -1155,7 +1155,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { if ( typeof obj === "string" ) { obj = obj.split( " " ); } - if ( $.isArray( obj ) ) { + if ( Array.isArray( obj ) ) { obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 }; } if ( "left" in obj ) { diff --git a/ui/widgets/spinner.js b/ui/widgets/spinner.js index 0bc1db230..6b860e785 100644 --- a/ui/widgets/spinner.js +++ b/ui/widgets/spinner.js @@ -344,7 +344,7 @@ $.widget( "ui.spinner", { var incremental = this.options.incremental; if ( incremental ) { - return $.isFunction( incremental ) ? + return typeof incremental === "function" ? incremental( i ) : Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 ); } diff --git a/ui/widgets/tabs.js b/ui/widgets/tabs.js index 14f94ae83..0eb69ebe1 100644 --- a/ui/widgets/tabs.js +++ b/ui/widgets/tabs.js @@ -95,7 +95,7 @@ $.widget( "ui.tabs", { // Take disabling tabs via class attribute from HTML // into account and update option properly. - if ( $.isArray( options.disabled ) ) { + if ( Array.isArray( options.disabled ) ) { options.disabled = $.uniqueSort( options.disabled.concat( $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { return that.tabs.index( li ); @@ -502,7 +502,7 @@ $.widget( "ui.tabs", { _setOptionDisabled: function( disabled ) { var currentItem, li, i; - if ( $.isArray( disabled ) ) { + if ( Array.isArray( disabled ) ) { if ( !disabled.length ) { disabled = false; } else if ( disabled.length === this.anchors.length ) { @@ -790,7 +790,7 @@ $.widget( "ui.tabs", { disabled = false; } else { index = this._getIndex( index ); - if ( $.isArray( disabled ) ) { + if ( Array.isArray( disabled ) ) { disabled = $.map( disabled, function( num ) { return num !== index ? num : null; } ); @@ -816,7 +816,7 @@ $.widget( "ui.tabs", { if ( $.inArray( index, disabled ) !== -1 ) { return; } - if ( $.isArray( disabled ) ) { + if ( Array.isArray( disabled ) ) { disabled = $.merge( [ index ], disabled ).sort(); } else { disabled = [ index ]; diff --git a/ui/widgets/tooltip.js b/ui/widgets/tooltip.js index 9a3a59063..d466410d7 100644 --- a/ui/widgets/tooltip.js +++ b/ui/widgets/tooltip.js @@ -72,7 +72,7 @@ $.widget( "ui.tooltip", { describedby.push( id ); elem .data( "ui-tooltip-id", id ) - .attr( "aria-describedby", $.trim( describedby.join( " " ) ) ); + .attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) ); }, _removeDescribedBy: function( elem ) { @@ -85,7 +85,7 @@ $.widget( "ui.tooltip", { } elem.removeData( "ui-tooltip-id" ); - describedby = $.trim( describedby.join( " " ) ); + describedby = String.prototype.trim.call( describedby.join( " " ) ); if ( describedby ) { elem.attr( "aria-describedby", describedby ); } else { |