External Libraries: Update Backbone.js to 1.4.0.

Upgrade Backbone to the latest stable version. Fix some issues in Media with `listenTo` which changed in this version, see https://backbonejs.org/#changelog.

Props desrosj, priyankkpatel, pierlo.
Fixes #47478.



git-svn-id: https://develop.svn.wordpress.org/trunk@46157 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Adam Silverstein 2019-09-17 17:18:32 +00:00
parent ed25bc3080
commit 823b0d2c64
6 changed files with 12 additions and 15 deletions

6
package-lock.json generated
View File

@ -4314,9 +4314,9 @@
"integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ=="
},
"backbone": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz",
"integrity": "sha1-TMgOp8sWMaxHSInOQPL4vGg7KZk=",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.4.0.tgz",
"integrity": "sha512-RLmDrRXkVdouTg38jcgHhyQ/2zjg7a8E6sz2zxfz21Hh17xDJYUHBZimVIt5fUyS8vbfpeSmTL3gUjTEvUV3qQ==",
"requires": {
"underscore": ">=1.8.3"
}

View File

@ -101,7 +101,7 @@
"@wordpress/url": "2.5.0",
"@wordpress/viewport": "2.3.0",
"@wordpress/wordcount": "2.2.0",
"backbone": "1.3.3",
"backbone": "1.4.0",
"clipboard": "2.0.4",
"element-closest": "^2.0.2",
"formdata-polyfill": "3.0.13",

View File

@ -14,17 +14,14 @@
* @augments Backbone.Model
* @mixin
* @mixes Backbone.Events
*
* @param {Array} states
*/
var StateMachine = function( states ) {
// @todo This is dead code. The states collection gets created in media.view.Frame._createStates.
this.states = new Backbone.Collection( states );
var StateMachine = function() {
return {
// Use Backbone's self-propagating `extend` inheritance method.
extend: Backbone.Model.extend
};
};
// Use Backbone's self-propagating `extend` inheritance method.
StateMachine.extend = Backbone.Model.extend;
_.extend( StateMachine.prototype, Backbone.Events,/** @lends wp.media.controller.StateMachine.prototype */{
/**
* Fetch a state.

View File

@ -66,7 +66,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{
this.details( this.model, this.controller.state().get('selection') );
}
this.listenTo( this.controller, 'attachment:compat:waiting attachment:compat:ready', this.updateSave );
this.listenTo( this.controller.states, 'attachment:compat:waiting attachment:compat:ready', this.updateSave );
},
/**
* @returns {wp.media.view.Attachment} Returns itself to allow chaining

View File

@ -19,7 +19,7 @@ MediaDetails = AttachmentDisplay.extend(/** @lends wp.media.view.MediaDetails.pr
initialize: function() {
_.bindAll(this, 'success');
this.players = [];
this.listenTo( this.controller, 'close', wp.media.mixin.unsetPlayers );
this.listenTo( this.controller.states, 'close', wp.media.mixin.unsetPlayers );
this.on( 'ready', this.setPlayer );
this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
this.on( 'media:setting:remove', this.render );

View File

@ -1170,7 +1170,7 @@ function wp_default_scripts( &$scripts ) {
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.8.3', 1 );
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.2.3', 1 );
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore', 'jquery' ), '1.4.0', 1 );
$scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array( 'underscore', 'jquery' ), false, 1 );
did_action( 'init' ) && $scripts->localize(