Customize: Use `input` event instead of `keyup` or `propertychange` events when listening for changes in `wp.customize.Element` instances.

Ensures that a control's `Element` is updated in response to pasting into the field. Also fixes issue where inputs using "new" HTML5 types (like `url` and `number`) were not updating in the preview during keystrokes. The use of `input` was previously blocked due to needing to support IE9, but this is no longer a concern since IE<11 is no longer supported.

See #38845, #28477.
Fixes #35832.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-09-18 19:11:48 +00:00
parent 10970701d7
commit 19e3d8bc41
3 changed files with 10 additions and 18 deletions

View File

@ -551,34 +551,26 @@ window.wp = window.wp || {};
this.element = api.ensure( element );
this.events = '';
if ( this.element.is('input, select, textarea') ) {
this.events += 'change';
if ( this.element.is( 'input, select, textarea' ) ) {
type = this.element.prop( 'type' );
this.events += ' change input';
synchronizer = api.Element.synchronizer.val;
if ( this.element.is('input') ) {
type = this.element.prop('type');
if ( api.Element.synchronizer[ type ] ) {
synchronizer = api.Element.synchronizer[ type ];
}
if ( 'text' === type || 'password' === type ) {
this.events += ' keyup';
} else if ( 'range' === type ) {
this.events += ' input propertychange';
}
} else if ( this.element.is('textarea') ) {
this.events += ' keyup';
if ( this.element.is( 'input' ) && api.Element.synchronizer[ type ] ) {
synchronizer = api.Element.synchronizer[ type ];
}
}
api.Value.prototype.initialize.call( this, null, $.extend( options || {}, synchronizer ) );
this._value = this.get();
update = this.update;
update = this.update;
refresh = this.refresh;
this.update = function( to ) {
if ( to !== refresh.call( self ) )
if ( to !== refresh.call( self ) ) {
update.apply( this, arguments );
}
};
this.refresh = function() {
self.set( refresh.call( self ) );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41386';
$wp_version = '4.9-alpha-41387';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.