Transitional monkey patch to make Marionette v3 compatible with v2.
Currently using v3.0.0-pre.5.
Include and execute this library directly after marionette prior to using the library.
You can turn off certain patches by passing an object setting patches to false.
If you are currently backporting v3 functionality or shimming in Radio for Wreqr you may need to remove these modifications.
-
In v2 many options passed on instantiation could be modified after instantiation. In v3, options are merged on instantiation and not used internally afterwards. To modify the option passed in on v3, modify the value on the instance itself.
-
Region: before:show / show events in v2 passed the view, the region, and options, but in v3 pass the region, the view and options
-
Region: before:empty / empty events in v3 now pass the region as the first argument
-
Region: before:destroy / destroy events in v3 now pass the region as the first argument
-
Region: show({forceShow: true}) was removed. In v3 a view is rendered if it was not previously and it is show if it was not shown previously. If you need to retrigger events, either re-render or empty/show again.
-
Application: In v2 options passed while instantiating an Application were merged onto the Application. This was removed in v3 and not re-implemented here.
-
Object destroy events now pass the view as the 1st argument.
-
CollectionView.isEmpty is no longer passed the collection
as the first argument.
-
CollectionView onAddChild
and onRemoveChild
are now passed the collectionView as the 1st argument and the childView as the second.
-
CollectionView.renderChildView was removed entirely
-
View.delegateEvents / View.undelegateEvents no longer delegate entity events. Those are delegated separately in v3.
-
View.isRendered / View.isDestroyed flags in v2 are now functions in v3. This is not accounted for here.
-
View.triggers in v2 passed a object to the handler containing the view, model, and collection. In v3 instead of this option, simply the view is passed (which will contain the model or collection anyhow).
-
View.serializeModel in v3 uses this.model
and does not take model
as an argument.
-
View.destroy in v3 doesn't call Backbone.View.remove
directly however all pieces of it are called. As long as someone isn't overriding remove in Backbone, this is a non-breaking change.
-
View destroy events now pass the view as the 1st argument.
-
View.modelEvents and View.collectionEvents were bound on delegateEvents
in v2, but it was separated in v3 into its own delegateEntityEvents
. Entity events are now only bound upon initialization.
-
View add:region
and remove:region
now pass the view as the 1st argument
-
View does not have an attached RegionManager
.
-
View childViewEvents
(previously named childEvents
) are calculated and cached when the events
has is delegated instead of on each trigger
.
-
View - the v2 Layout's destroyImmediate is the default functionality of View's in v3.
-
LayoutView.regions were passed the options
from the view's instantiation due to the getOption
not being available. This is no longer the case in v3 and getOption
(or this.options
) will work to get options.