Admin: Don't use the keyup event in addition to the input event.

The `keyup` event was used to provide support for IE8, where which doesn't support the `input` event. As we dropped IE8 support some time ago, this was simply adding unnecessary complexity and double-event triggers.

Props dlh, afercia.
Fixes #32882.


Built from https://develop.svn.wordpress.org/trunk@44539


git-svn-id: http://core.svn.wordpress.org/trunk@44370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2019-01-10 02:57:50 +00:00
parent 8eb90ac374
commit 2772e5ec06
9 changed files with 13 additions and 39 deletions

View File

@ -156,7 +156,6 @@
events: { events: {
'input #menu-items-search': 'debounceSearch', 'input #menu-items-search': 'debounceSearch',
'keyup #menu-items-search': 'debounceSearch',
'focus .menu-item-tpl': 'focus', 'focus .menu-item-tpl': 'focus',
'click .menu-item-tpl': '_submit', 'click .menu-item-tpl': '_submit',
'click #custom-menu-item-submit': '_submitLink', 'click #custom-menu-item-submit': '_submitLink',

File diff suppressed because one or more lines are too long

View File

@ -144,7 +144,6 @@
events: { events: {
'input #widgets-search': 'search', 'input #widgets-search': 'search',
'keyup #widgets-search': 'search',
'focus .widget-tpl' : 'focus', 'focus .widget-tpl' : 'focus',
'click .widget-tpl' : '_submit', 'click .widget-tpl' : '_submit',
'keypress .widget-tpl' : '_submit', 'keypress .widget-tpl' : '_submit',

File diff suppressed because one or more lines are too long

View File

@ -873,26 +873,14 @@
}, },
attachQuickSearchListeners : function() { attachQuickSearchListeners : function() {
var searchTimer, var searchTimer;
inputEvent;
// Prevent form submission. // Prevent form submission.
$( '#nav-menu-meta' ).on( 'submit', function( event ) { $( '#nav-menu-meta' ).on( 'submit', function( event ) {
event.preventDefault(); event.preventDefault();
}); });
/* $( '#nav-menu-meta' ).on( 'input', '.quick-search', function() {
* Use feature detection to determine whether inputs should use
* the `keyup` or `input` event. Input is preferred but lacks support
* in legacy browsers. See changeset 34078, see also ticket #26600#comment:59
*/
if ( 'oninput' in document.createElement( 'input' ) ) {
inputEvent = 'input';
} else {
inputEvent = 'keyup';
}
$( '#nav-menu-meta' ).on( inputEvent, '.quick-search', function() {
var $this = $( this ); var $this = $( this );
$this.attr( 'autocomplete', 'off' ); $this.attr( 'autocomplete', 'off' );

File diff suppressed because one or more lines are too long

View File

@ -17,19 +17,7 @@
$toggleButton, $toggleButton,
$submitButtons, $submitButtons,
$submitButton, $submitButton,
currentPass, currentPass;
inputEvent;
/*
* Use feature detection to determine whether password inputs should use
* the `keyup` or `input` event. Input is preferred but lacks support
* in legacy browsers.
*/
if ( 'oninput' in document.createElement( 'input' ) ) {
inputEvent = 'input';
} else {
inputEvent = 'keyup';
}
function generatePassword() { function generatePassword() {
if ( typeof zxcvbn !== 'function' ) { if ( typeof zxcvbn !== 'function' ) {
@ -71,7 +59,7 @@
.addClass( $pass1[0].className ) .addClass( $pass1[0].className )
.data( 'pw', $pass1.data( 'pw' ) ) .data( 'pw', $pass1.data( 'pw' ) )
.val( $pass1.val() ) .val( $pass1.val() )
.on( inputEvent, function () { .on( 'input', function () {
if ( $pass1Text.val() === currentPass ) { if ( $pass1Text.val() === currentPass ) {
return; return;
} }
@ -86,7 +74,7 @@
generatePassword(); generatePassword();
} }
$pass1.on( inputEvent + ' pwupdate', function () { $pass1.on( 'input' + ' pwupdate', function () {
if ( $pass1.val() === currentPass ) { if ( $pass1.val() === currentPass ) {
return; return;
} }
@ -188,7 +176,7 @@
* This fixes the issue by copying any changes from the hidden * This fixes the issue by copying any changes from the hidden
* pass2 field to the pass1 field, then running check_pass_strength. * pass2 field to the pass1 field, then running check_pass_strength.
*/ */
$pass2 = $('#pass2').on( inputEvent, function () { $pass2 = $( '#pass2' ).on( 'input', function () {
if ( $pass2.val().length > 0 ) { if ( $pass2.val().length > 0 ) {
$pass1.val( $pass2.val() ); $pass1.val( $pass2.val() );
$pass2.val(''); $pass2.val('');
@ -336,7 +324,7 @@
current_name = select.val(), current_name = select.val(),
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' ); greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength ); $( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
$('#pass-strength-result').show(); $('#pass-strength-result').show();
$('.color-palette').click( function() { $('.color-palette').click( function() {
$(this).siblings('input[name="admin_color"]').prop('checked', true); $(this).siblings('input[name="admin_color"]').prop('checked', true);

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44538'; $wp_version = '5.1-alpha-44539';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.