WordPress.org

Make WordPress Core

Changeset 41387


Ignore:
Timestamp:
09/18/2017 07:10:38 PM (2 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/customize-base.js

    r41374 r41387  
    552552            this.events = '';
    553553
    554             if ( this.element.is('input, select, textarea') ) {
    555                 this.events += 'change';
     554            if ( this.element.is( 'input, select, textarea' ) ) {
     555                type = this.element.prop( 'type' );
     556                this.events += ' change input';
    556557                synchronizer = api.Element.synchronizer.val;
    557558
    558                 if ( this.element.is('input') ) {
    559                     type = this.element.prop('type');
    560                     if ( api.Element.synchronizer[ type ] ) {
    561                         synchronizer = api.Element.synchronizer[ type ];
    562                     }
    563                     if ( 'text' === type || 'password' === type ) {
    564                         this.events += ' keyup';
    565                     } else if ( 'range' === type ) {
    566                         this.events += ' input propertychange';
    567                     }
    568                 } else if ( this.element.is('textarea') ) {
    569                     this.events += ' keyup';
     559                if ( this.element.is( 'input' ) && api.Element.synchronizer[ type ] ) {
     560                    synchronizer = api.Element.synchronizer[ type ];
    570561                }
    571562            }
     
    574565            this._value = this.get();
    575566
    576             update  = this.update;
     567            update = this.update;
    577568            refresh = this.refresh;
    578569
    579570            this.update = function( to ) {
    580                 if ( to !== refresh.call( self ) )
     571                if ( to !== refresh.call( self ) ) {
    581572                    update.apply( this, arguments );
     573                }
    582574            };
    583575            this.refresh = function() {
Note: See TracChangeset for help on using the changeset viewer.