Skip to content

v2.0.0

Compare
Choose a tag to compare
@jamiebuilds jamiebuilds released this 18 Jun 01:35
· 1333 commits to master since this release

If you are looking to upgrade a 1.x app please use https://github.com/marionettejs/Marionette.Upgrade

Questions? Need help? Join us on gitter.im
https://gitter.im/marionettejs/backbone.marionette

The Changes:

General

  • API change: Removed the Marionette.$ proxy. We are now using Backbone.$ instead.
  • API change: All instances of the word type in the API have been replaced with the word class. For instance:
    • regionType => regionClass
    • ChildViewType => ChildViewClass
  • triggerMethod now calls the method before triggering the event. Previously it was the other way around.
  • jQuery deferred objects can now be replaced via the global Marionette.Deferred object.
  • Stricter JSHint rules were implemented for more consistent style across the codebase.
  • A new property, Marionette.VERSION, was added.
  • Most classes now have getOption attached to their instances, taking advantage of the new helper function Marionette.proxyGetOption
  • Most classes now have bindEntityEvents attached to their instances, taking advantage of the new helper function Marionette.proxyBindEntityEvents
  • Most classes now have unbindEntityEvents attached to their instances, taking advantage of the new helper function Marionette.proxyUnbindEntityEvents
  • There are now only two built versions of Marionette, and both come in UMD wrappers. The first is the core by itself and the second is the bundled version (with Wreqr and Babysitter).

Applications and Modules

  • API change: The arguments of a Module’s initialize function are now consistent with Module constructor argument order. Previously they were inconsistent with one another.
initialize: function( moduleName, app, options ) {
  • API change: Application’s initialize triggerMethods have been renamed to start, which is more descriptive of what is actually happening. More specifically, initialize:before and initialize:after are now before:start and start, respectively. Note that no functionality has been lost with this change; it is merely a changing of names.
  • The Application message system has been replaced with a channel named “global”
  • Applications have two new triggerMethods: before:region:add and before:region:remove to complement their existing region events.

Controllers

  • API change: stopListening is now called after the destroy triggerMethod is called.
  • API change: close has been renamed to destroy to emphasize the fact that an instance should not be reused, or ‘opened,’ after it is destroyed.
  • The before:destroy triggerMethod has been added to controllers. Due to this your controllers can now implement a onBeforeDestroy method to be invoked just before a Controller has been destroyed.

Behaviors

  • Behaviors now support a means to group behaviors together. Any Behavior can now have a behavior key of its own, very similar to how a view can have behaviors.

Regions

  • API change: Regions now throw an error when show is called with a nonexistent el. Previously this was a silent failure.
  • Region’s ensureEl has been renamed to _ensureElement
  • API change: Regions now expose region.el and region.$el, just like View’s.
    Due to this change if you were depending on region.el to be a string selector you must update your code to use region.$el.selector.
  • API change: The open method has been renamed to attachHtml.
  • API change: The close method has been renamed to empty, as it functions quite differently from a View’s close method.
  • Regions now use .innerHtml when clearing contents as compared this this.$el.empty().
  • region.show now return this, just like how a view’s render returns this.
  • Regions trigger two new events, before:swap and swap, when it swaps views when calling show.
  • Region’s el can now be a DOM node / DOM string selector / Jquery selector instance, just like a View’s el.
  • Calling show on a region with the same view that is currently shown is now a noop. Previously the view would be re-rendered. You can force a rerender by passing forceShow: true with the region show options.
    MyApp.mainRegion.show(myView, {forceShow: true});
  • Regions now fire a new triggerMethod, before:destroy, before they are destroyed.
  • There is a new triggerMethod: before:empty

RegionManagers

  • getRegions: returns all of the regions of a given RegionManager instance as an Array. This method is also exposed to the Layout and Application as getRegions.

Views

  • API change: Layout is now called LayoutView.
  • API change: Renamed close to destroy for views. Close was a confusing verb for users who thought that they could be reopened. The verb destroy makes it more clear that once a view is destroyed you can not reuse it.
  • API change: Returning false from onBeforeClose no longer prevents the view from closing. This behavior was inconsistent with the rest of the library, and would require far too much logic to respect in all cases. Instead of returning false, you should handle your logic before calling close on the view.
  • API change: appendHtml has been renamed to attachHtml. appendBuffer has been renamed to attachBuffer
  • API change: Removes duplicate and inconsistent itemView events. No functionality was lost with this change; simply use the unprefixed version instead. For instance, use before:render instead of item:before:render.
    • item:before:render
    • item:rendered
    • itemview:item:before:render
    • itemview:item:rendered
    • itemview:item:before:close
    • itemview:item:closed
  • item:before:destroy
    • item:destroyed
  • API change: childEvents callbacks no longer receives the event name as the first argument, making the arguments of those callbacks consistent with standard trigger callbacks.
  • API change: itemView within a collectionView is now known as childView. This removes confusion for new users as to the fact that you can show any type of view in your collectionView. All CollectionView methods that referenced itemView now use the same childView as well. For instance, getItemView is now getChildView. Do note that CompositeViews extend from CollectionView, so these API changes affect that Class as well.
  • API change: collectionView, and compositeView, have new listener callbacks for their underlying collection. addChildView is now _onCollectionAdd and removeItemView is now _onCollectionRemove
  • API change: renderModel for compositeView is now called _renderRoot.
  • API change: collectionView’s and compositeView’s method onChildRemove is now known as _onCollectionRemove
  • Bug fix: UI interpolation for events no longer mutates the prototypes event hash
  • Bug fix: UI interpolation for events now works properly if you dynamically add @ui interpolated events to a view instance and call delegateEvents on the view instance.
  • A views html content insertion can now be overridden on a per view basis via attachElContent to render in a non standard way for optimization and not standard use cases. This is available to all views with templates: Item View, Layout View, and Composite View.

For example, using innerHTML instead of $el.html

attachElContent: function(html) {
 this.el.innerHTML = html;
 return this;
}
  • A new triggerMethod was added to collectionView: before:remove:child.
  • Collection and Composite Views now respect the collection comparator when rendering and when new views are added. This means that your collection will stay in order on the DOM.
  • collectionView and compositeView now have an optional emptyViewOptions property which allows you to customize your emptyView.
  • addItemView is now addChild : This will not be a one to one conversion and will require you to update your implementation if you are not calling super
  • Layouts now facilitate overriding the default RegionManager with a custom Class through the use of the getRegionManager method.
  • LayoutViews now lets you specify the regions hash as an option upon instantiation. Previously you need to create a brand new LayoutView class to set the regions.
new Marionette.LayoutView({
 regions: {
   "cat": ".doge",
   "wow": {
     selector: ".such",
     regionClass: Coin
   }
 }
})
  • LayoutViews have a new property: regionOptions. These are the options that are passed into each region upon creation.
Cleanup
  • Removes calls to MyClass.prototype.constructor, instead simply referencing MyClass.
  • Swapped Jasmine for Mocha for unit tests
  • All code is now instrumented via coveralls for every PR. This gives a code coverage statistic for us to identify testing gaps.

For a closer look at each change, refer to the https://github.com/Puppets/marionette-changelog-detail.