diff --git a/package-lock.json b/package-lock.json index c09426b894..444d08baf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index 4bf1a8435c..71a8b5e185 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/js/media/controllers/state-machine.js b/src/js/media/controllers/state-machine.js index 626f6c33ce..bb7fb31b27 100644 --- a/src/js/media/controllers/state-machine.js +++ b/src/js/media/controllers/state-machine.js @@ -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. diff --git a/src/js/media/views/attachment.js b/src/js/media/views/attachment.js index 240f05c0ee..14d5e460db 100644 --- a/src/js/media/views/attachment.js +++ b/src/js/media/views/attachment.js @@ -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 diff --git a/src/js/media/views/media-details.js b/src/js/media/views/media-details.js index 4b9a7c1a0d..ae643a3941 100644 --- a/src/js/media/views/media-details.js +++ b/src/js/media/views/media-details.js @@ -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 ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 5366bfbcd0..eeb76639a7 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -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(