Make WordPress Core

Changeset 39547


Ignore:
Timestamp:
12/09/2016 01:58:18 AM (8 years ago)
Author:
westonruter
Message:

Customize: Allow (optional) url parameter to be omitted in intercepted calls to history.pushState() and history.replaceState() in customize preview.

Fixes issue where calls without the url parameter erroneously end up rewriting the location path to /undefined.

Props Christian1012, westonruter.
Fixes #39175.

File:
1 edited

Legend:

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

    r39345 r39547  
    5050            return function historyReplaceState( data, title, url ) {
    5151                currentHistoryState = data;
    52                 return nativeReplaceState.call( history, data, title, injectUrlWithState( url ) );
     52                return nativeReplaceState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url );
    5353            };
    5454        } )( history.replaceState );
     
    5757            return function historyPushState( data, title, url ) {
    5858                currentHistoryState = data;
    59                 return nativePushState.call( history, data, title, injectUrlWithState( url ) );
     59                return nativePushState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url );
    6060            };
    6161        } )( history.pushState );
Note: See TracChangeset for help on using the changeset viewer.