--- a/wp/wp-includes/js/jquery/ui/autocomplete.js Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/js/jquery/ui/autocomplete.js Tue Sep 27 16:37:53 2022 +0200
@@ -1,5 +1,5 @@
/*!
- * jQuery UI Autocomplete 1.12.1
+ * jQuery UI Autocomplete 1.13.1
* http://jqueryui.com
*
* Copyright jQuery Foundation and other contributors
@@ -17,6 +17,8 @@
//>>css.theme: ../../themes/base/theme.css
( function( factory ) {
+ "use strict";
+
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
@@ -30,10 +32,11 @@
// Browser globals
factory( jQuery );
}
-}( function( $ ) {
+} )( function( $ ) {
+"use strict";
$.widget( "ui.autocomplete", {
- version: "1.12.1",
+ version: "1.13.1",
defaultElement: "<input>",
options: {
appendTo: null,
@@ -59,6 +62,7 @@
requestIndex: 0,
pending: 0,
+ liveRegionTimer: null,
_create: function() {
@@ -100,58 +104,58 @@
suppressKeyPressRepeat = false;
var keyCode = $.ui.keyCode;
switch ( event.keyCode ) {
- case keyCode.PAGE_UP:
- suppressKeyPress = true;
- this._move( "previousPage", event );
- break;
- case keyCode.PAGE_DOWN:
- suppressKeyPress = true;
- this._move( "nextPage", event );
- break;
- case keyCode.UP:
- suppressKeyPress = true;
- this._keyEvent( "previous", event );
- break;
- case keyCode.DOWN:
- suppressKeyPress = true;
- this._keyEvent( "next", event );
- break;
- case keyCode.ENTER:
-
- // when menu is open and has focus
- if ( this.menu.active ) {
-
- // #6055 - Opera still allows the keypress to occur
- // which causes forms to submit
+ case keyCode.PAGE_UP:
+ suppressKeyPress = true;
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ suppressKeyPress = true;
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ suppressKeyPress = true;
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
suppressKeyPress = true;
- event.preventDefault();
- this.menu.select( event );
- }
- break;
- case keyCode.TAB:
- if ( this.menu.active ) {
- this.menu.select( event );
- }
- break;
- case keyCode.ESCAPE:
- if ( this.menu.element.is( ":visible" ) ) {
- if ( !this.isMultiLine ) {
- this._value( this.term );
+ this._keyEvent( "next", event );
+ break;
+ case keyCode.ENTER:
+
+ // when menu is open and has focus
+ if ( this.menu.active ) {
+
+ // #6055 - Opera still allows the keypress to occur
+ // which causes forms to submit
+ suppressKeyPress = true;
+ event.preventDefault();
+ this.menu.select( event );
+ }
+ break;
+ case keyCode.TAB:
+ if ( this.menu.active ) {
+ this.menu.select( event );
}
- this.close( event );
+ break;
+ case keyCode.ESCAPE:
+ if ( this.menu.element.is( ":visible" ) ) {
+ if ( !this.isMultiLine ) {
+ this._value( this.term );
+ }
+ this.close( event );
- // Different browsers have different default behavior for escape
- // Single press can mean undo or clear
- // Double press in IE means clear the whole form
- event.preventDefault();
- }
- break;
- default:
- suppressKeyPressRepeat = true;
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
+ }
+ break;
+ default:
+ suppressKeyPressRepeat = true;
- // search timeout should be triggered before the input value is changed
- this._searchTimeout( event );
- break;
+ // search timeout should be triggered before the input value is changed
+ this._searchTimeout( event );
+ break;
}
},
keypress: function( event ) {
@@ -169,18 +173,18 @@
// Replicate some key handlers to allow them to repeat in Firefox and Opera
var keyCode = $.ui.keyCode;
switch ( event.keyCode ) {
- case keyCode.PAGE_UP:
- this._move( "previousPage", event );
- break;
- case keyCode.PAGE_DOWN:
- this._move( "nextPage", event );
- break;
- case keyCode.UP:
- this._keyEvent( "previous", event );
- break;
- case keyCode.DOWN:
- this._keyEvent( "next", event );
- break;
+ case keyCode.PAGE_UP:
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ this._keyEvent( "next", event );
+ break;
}
},
input: function( event ) {
@@ -196,11 +200,6 @@
this.previous = this._value();
},
blur: function( event ) {
- if ( this.cancelBlur ) {
- delete this.cancelBlur;
- return;
- }
-
clearTimeout( this.searching );
this.close( event );
this._change( event );
@@ -216,31 +215,24 @@
role: null
} )
.hide()
+
+ // Support: IE 11 only, Edge <= 14
+ // For other browsers, we preventDefault() on the mousedown event
+ // to keep the dropdown from taking focus from the input. This doesn't
+ // work for IE/Edge, causing problems with selection and scrolling (#9638)
+ // Happily, IE and Edge support an "unselectable" attribute that
+ // prevents an element from receiving focus, exactly what we want here.
+ .attr( {
+ "unselectable": "on"
+ } )
.menu( "instance" );
this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
this._on( this.menu.element, {
mousedown: function( event ) {
- // prevent moving focus out of the text field
+ // Prevent moving focus out of the text field
event.preventDefault();
-
- // IE doesn't prevent moving focus even with event.preventDefault()
- // so we set a flag to know when we should ignore the blur event
- this.cancelBlur = true;
- this._delay( function() {
- delete this.cancelBlur;
-
- // Support: IE 8 only
- // Right clicking a menu item or selecting text from the menu items will
- // result in focus moving out of the input. However, we've already received
- // and ignored the blur event because of the cancelBlur flag set above. So
- // we restore focus to ensure that the menu closes properly based on the user's
- // next actions.
- if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
- this.element.trigger( "focus" );
- }
- } );
},
menufocus: function( event, ui ) {
var label, item;
@@ -271,9 +263,11 @@
// Announce the value in the liveRegion
label = ui.item.attr( "aria-label" ) || item.value;
- if ( label && $.trim( label ).length ) {
- this.liveRegion.children().hide();
- $( "<div>" ).text( label ).appendTo( this.liveRegion );
+ if ( label && String.prototype.trim.call( label ).length ) {
+ clearTimeout( this.liveRegionTimer );
+ this.liveRegionTimer = this._delay( function() {
+ this.liveRegion.html( $( "<div>" ).text( label ) );
+ }, 100 );
}
},
menuselect: function( event, ui ) {
@@ -383,7 +377,7 @@
_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 ) );
@@ -455,7 +449,7 @@
_response: function() {
var index = ++this.requestIndex;
- return $.proxy( function( content ) {
+ return function( content ) {
if ( index === this.requestIndex ) {
this.__response( content );
}
@@ -464,7 +458,7 @@
if ( !this.pending ) {
this._removeClass( "ui-autocomplete-loading" );
}
- }, this );
+ }.bind( this );
},
__response: function( content ) {
@@ -583,7 +577,7 @@
return;
}
if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
- this.menu.isLastItem() && /^next/.test( direction ) ) {
+ this.menu.isLastItem() && /^next/.test( direction ) ) {
if ( !this.isMultiLine ) {
this._value( this.term );
@@ -624,7 +618,7 @@
var editable = element.prop( "contentEditable" );
if ( editable === "inherit" ) {
- return this._isContentEditable( element.parent() );
+ return this._isContentEditable( element.parent() );
}
return editable === "true";
@@ -668,11 +662,13 @@
} else {
message = this.options.messages.noResults;
}
- this.liveRegion.children().hide();
- $( "<div>" ).text( message ).appendTo( this.liveRegion );
+ clearTimeout( this.liveRegionTimer );
+ this.liveRegionTimer = this._delay( function() {
+ this.liveRegion.html( $( "<div>" ).text( message ) );
+ }, 100 );
}
} );
return $.ui.autocomplete;
-} ) );
+} );