Backbone and Underscore updated to latest versions

WordPress trunk upgrades Backbone and Underscore to the latest versions (they were last updated two years ago in [27233]). Backbone is upgraded from 1.1.2 to 1.2.3 and Underscore is upgraded from 1.6.0 to 1.8.3; see #34350 and [36546].

The new versions of Backbone and Underscore offer numerous small bug fixes, some optimizations and some small improvements. Check the Backbone changelog and Underscore changelog for the full details.

The upgraded versions include some 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 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.
  • Since Underscore 1.7, _.union and _.difference now only work with arrays and not variadic args.  If you were passing either a list of arguments, wrap it with [ ] to create an array.

 

#4-5, #dev-notes