Update Backbone and Underscore to the latest versions.

Backbone, from 1.1.2 to 1.2.3. Underscore, from 1.6.0 to 1.8.3.

The new versions of Backbone and Underscore offer numerous small bug fixes and some optimizations and other improvements. Check the [http://backbonejs.org/#changelog Backbone changelog] and [http://underscorejs.org/#changelog Underscore changelog] for the full details. 

The new versions include some significant changes that may break existing code. Plugins or themes that rely on the bundled Backbone and/or Underscore libraries should carefully check functionality with the latest versions and run any available unit tests to ensure compatibility.

Some changes of note that were addressed in core as part of this upgrade:

* `_.flatten` no longer works with objects since Underscore.js 1.7. `_.flatten()` working with objects was an unintended side-affect of the implementation, see [https://github.com/jashkenas/underscore/issues/1904#issuecomment-60241576 underscore#1904]. Check any `_flatten` usage and only flatten arrays.
* As of Backbone 1.2.0, you can no longer modify the `events` hash or your view's `el` property in `initialize`, so don't try to modify them there. 
* Since Underscore 1.7, Underscore templates no longer accept an initial data object. `_.template` always returns a function now so make sure you use it that way.

Props adamsilverstein.
Fixes #34350.

git-svn-id: https://develop.svn.wordpress.org/trunk@36546 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-02-17 15:21:09 +00:00
parent f9f0015a90
commit 1750b09775
8 changed files with 1512 additions and 1013 deletions

View File

@ -663,7 +663,7 @@
*/
_setupReorderUI: function() {
var self = this, selectSidebarItem, $moveWidgetArea,
$reorderNav, updateAvailableSidebars;
$reorderNav, updateAvailableSidebars, template;
/**
* select the provided sidebar list item in the move widget area
@ -681,8 +681,10 @@
* Add the widget reordering elements to the widget control
*/
this.container.find( '.widget-title-action' ).after( $( api.Widgets.data.tpl.widgetReorderNav ) );
$moveWidgetArea = $(
_.template( api.Widgets.data.tpl.moveWidgetArea, {
template = _.template( api.Widgets.data.tpl.moveWidgetArea );
$moveWidgetArea = $( template( {
sidebars: _( api.Widgets.registeredSidebars.toArray() ).pluck( 'attributes' )
} )
);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -728,14 +728,17 @@ MediaDetails = AttachmentDisplay.extend({
this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
this.on( 'media:setting:remove', this.render );
this.on( 'media:setting:remove', this.setPlayer );
this.events = _.extend( this.events, {
AttachmentDisplay.prototype.initialize.apply( this, arguments );
},
events: function(){
return _.extend( {
'click .remove-setting' : 'removeSetting',
'change .content-track' : 'setTracks',
'click .remove-track' : 'setTracks',
'click .add-media-source' : 'addSource'
} );
AttachmentDisplay.prototype.initialize.apply( this, arguments );
}, AttachmentDisplay.prototype.events );
},
prepare: function() {

View File

@ -23,14 +23,17 @@ MediaDetails = AttachmentDisplay.extend({
this.on( 'media:setting:remove', wp.media.mixin.unsetPlayers, this );
this.on( 'media:setting:remove', this.render );
this.on( 'media:setting:remove', this.setPlayer );
this.events = _.extend( this.events, {
AttachmentDisplay.prototype.initialize.apply( this, arguments );
},
events: function(){
return _.extend( {
'click .remove-setting' : 'removeSetting',
'change .content-track' : 'setTracks',
'click .remove-track' : 'setTracks',
'click .add-media-source' : 'addSource'
} );
AttachmentDisplay.prototype.initialize.apply( this, arguments );
}, AttachmentDisplay.prototype.events );
},
prepare: function() {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -314,8 +314,8 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'json2', "/wp-includes/js/json2$suffix.js", array(), '2015-05-03' );
did_action( 'init' ) && $scripts->add_data( 'json2', 'conditional', 'lt IE 8' );
$scripts->add( 'underscore', "/wp-includes/js/underscore$dev_suffix.js", array(), '1.6.0', 1 );
$scripts->add( 'backbone', "/wp-includes/js/backbone$dev_suffix.js", array( 'underscore','jquery' ), '1.1.2', 1 );
$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( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 );
did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array(