JavaScript: when starting Backbone history, stop if previously started.

Prevent a potential error condition if Backbone history is started by a plugin or theme before core tries to start it. 

Props tfrommen.
Fixes #39612.


git-svn-id: https://develop.svn.wordpress.org/trunk@40076 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
adamsilverstein 2017-02-17 21:59:37 +00:00
parent 0efaf5ddc5
commit 0d73b031c8
4 changed files with 15 additions and 0 deletions

View File

@ -411,6 +411,9 @@ window.wp = window.wp || {};
// Start the router if browser supports History API
if ( window.history && window.history.pushState ) {
this.router = new revisions.Router({ model: this });
if ( Backbone.History.started ) {
Backbone.history.stop();
}
Backbone.history.start({ pushState: true });
}
},

View File

@ -1431,6 +1431,9 @@ themes.Run = {
this.view.render();
this.routes();
if ( Backbone.History.started ) {
Backbone.history.stop();
}
Backbone.history.start({
root: themes.data.settings.adminUrl,
pushState: true,
@ -1884,6 +1887,9 @@ themes.RunInstaller = {
this.view.render();
this.routes();
if ( Backbone.History.started ) {
Backbone.history.stop();
}
Backbone.history.start({
root: themes.data.settings.adminUrl,
pushState: true,

View File

@ -844,6 +844,9 @@ Manage = MediaFrame.extend({
startHistory: function() {
// Verify pushState support and activate
if ( window.history && window.history.pushState ) {
if ( Backbone.History.started ) {
Backbone.history.stop();
}
Backbone.history.start( {
root: window._wpMediaGridSettings.adminUrl,
pushState: true

View File

@ -259,6 +259,9 @@ Manage = MediaFrame.extend({
startHistory: function() {
// Verify pushState support and activate
if ( window.history && window.history.pushState ) {
if ( Backbone.History.started ) {
Backbone.history.stop();
}
Backbone.history.start( {
root: window._wpMediaGridSettings.adminUrl,
pushState: true