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.

Built from https://develop.svn.wordpress.org/trunk@40076


git-svn-id: http://core.svn.wordpress.org/trunk@40013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2017-02-17 22:00:42 +00:00
parent 518ff1576b
commit c7b217cee9
7 changed files with 16 additions and 4 deletions

View File

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

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

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

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.8-alpha-40074'; $wp_version = '4.8-alpha-40076';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.