Customize: Verify availability of `history.replaceState` (in IE9) before attempting to populate `changeset_uuid` parameter.

Props westonruter, timmydcrawford for testing.
Amends [39686].
See #39227.
Fixes #40405.


git-svn-id: https://develop.svn.wordpress.org/trunk@40405 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-04-10 21:14:50 +00:00
parent 1abf42b45e
commit 1b9c964e81
1 changed files with 9 additions and 5 deletions

View File

@ -4762,6 +4762,12 @@
*/
populateChangesetUuidParam = function( isIncluded ) {
var urlParser, queryParams;
// Abort on IE9 which doesn't support history management.
if ( ! history.replaceState ) {
return;
}
urlParser = document.createElement( 'a' );
urlParser.href = location.href;
queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) );
@ -4780,11 +4786,9 @@
history.replaceState( {}, document.title, urlParser.href );
};
if ( history.replaceState ) {
changesetStatus.bind( function( newStatus ) {
populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus );
} );
}
changesetStatus.bind( function( newStatus ) {
populateChangesetUuidParam( '' !== newStatus && 'publish' !== newStatus );
} );
// Expose states to the API.
api.state = state;