From 3669b4726087be0fe3c0a88aa8b811077d07245e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 9 Dec 2016 01:58:18 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@39547 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/customize-preview.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/customize-preview.js b/src/wp-includes/js/customize-preview.js index a4cb196dc1..026706e314 100644 --- a/src/wp-includes/js/customize-preview.js +++ b/src/wp-includes/js/customize-preview.js @@ -49,14 +49,14 @@ history.replaceState = ( function( nativeReplaceState ) { return function historyReplaceState( data, title, url ) { currentHistoryState = data; - return nativeReplaceState.call( history, data, title, injectUrlWithState( url ) ); + return nativeReplaceState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url ); }; } )( history.replaceState ); history.pushState = ( function( nativePushState ) { return function historyPushState( data, title, url ) { currentHistoryState = data; - return nativePushState.call( history, data, title, injectUrlWithState( url ) ); + return nativePushState.call( history, data, title, 'string' === typeof url && url.length > 0 ? injectUrlWithState( url ) : url ); }; } )( history.pushState );