See upgrading guide if you're using old chaplin version and want to upgrade.
- Makes Chaplin work correctly with latest Lodash.
- Fixes invalid
CollectionViewbehavior in IE11. - Added
ms-appxto theLayout's list of supported protocols by default.
- A few bugfixes.
route.previousis nowundefinedinstead of an empty object if there is no previous object.
- Renamed
Controller#composetoController#reuse - Added
trailingoption forRouterwhich will:- When
false(default), strip accident route slashes:/users/=>/users - When
true, append all route slashes:/users=>/users/ - When
null, do nothing (like before):/users!=/users/
- When
- Normalize URI handling with trailing slashes
- Added support for optional
Routeparams, like this:/users/(:user) route.previousparam of controller actions is now saved only once.- Fixed bug when last char was removed from query string
- Added support for Exoskeleton 0.6. Previous versions are now incompatible.
- Removed
Delayer. Use separate Delayer package if you want to use it. Chaplin.helperswere merged withChaplin.utils. Useutilsnow forreverseandredirectTo.CollectionView#filternow ignores arguments if they are not functions. Useful if you want to call it on some DOM event fromeventshash.CollectionView#listSelectorcan now also be a function.Dispatchernow loads common.js code on next event loop tick (setTimeout load, 0) instead of previous fully synchronous behaviour to match AMD.
- Fixed view regions.
- Fixed filtering of collection view elements.
- Backbone.History is now used as Chaplin.History if it's patched (with query string support).
- Added support for Exoskeleton — faster and leaner Backbone.
- Thanks to that, you can now use Chaplin without underscore or jQuery
dependencies at all! Just Exoskeleton and Chaplin.
Make sure to set
window._toBackbone.utilsin no-deps environment.
Dispatcher#dispatchnow checks ifoptions.queryhash was changed.Route#reversenow won't add a ? symbol at the end of a returned url if you pass an empty object as aqueryparameter (second one)utils.queryParams.stringifywill now ignoreundefinedandnullvalues
- Chaplin internals now use Request / Response pattern instead of
bang
!events. New system also allows to return values. The syntax is so:mediator.setHandler(name, function),mediator.execute(name, args...). Removed events:!router:route,!router:routeByName(usehelpers.redirectTo)!router:changeURL!composer:compose,!composer:retrieve!region:register,!region:unregister!adjustTitle(usemediator.execute('adjustTitle', name)orController#adjustTitle). AnadjustTitleevent would be triggered after title is set.
- Improved
Chaplin.Controller:Controller#composemethod now:- by default, returns the composition itself
- if composition body returned a promise, it returns a promise too
- Removed
Controller#redirectToRoute. UseController#redirectTo. redirectTonow takes route name by default. If you want to pass URL, use it asredirectTo({url: 'URL'}).
- Improved
Chaplin.View:- Added
noWrapoption that allows to disable Backbone top-level element bound to view class. - Added
optionNamesproperty that contains a list of options that will be picked from an object passed to View, when initialising it. Property allows to simply extend it in your child classes:optionNames: ParentView.prototype.optionNames.concat(['template']) - Views now appended to DOM only if they were not there.
- Added
- Improved
Chaplin.Layout:- When push state is disabled, internal links are handled as if they had
#(gh-664).
- When push state is disabled, internal links are handled as if they had
- Improved
Chaplin.helpers:- Added
helpers.redirectTowhich allows to redirect to other route or url.
- Added
- Improved
Chaplin.utils:- Added
utils.queryParams.{stringify,parse}. utils.getPrototypeChainnow returns prototypes from oldest to newest, to matchutils.getAllPropertyVersions.
- Added
- Improved
Chaplin.Router:Route#reverse(as well asRouter#reverse) are now able to add query parameters to the reversed URL, no matter if they are already stringified or not when passed into the reverse (as a third parameter).Route#matchesimproved not to returntruewhen the onlycontrolleroractionparameter passed.- Fixed
getCurrentQueryerror whenpushStateis disabled (gh-671). - Query params are now not copied to next routes (gh-677).
- Improved
Chaplin.Application:- Renamed
startRoutingtostart, the following method also does freezing of app object.
- Renamed
- Temporarily added
Chaplin.Historythat overridesBackbone.History. It won't not ignore query string history as compared to Backbone (gh-577).
Special thanks to Andrew Yankovsky.
Chaplin now provides universal build for Common.js and AMD.
- Improved
Chaplin.Application:- Application is now initialized by default with
new Applicationconstructor method instead ofApplication#initialize. - Added default
Application#initializefunctionality.
- Application is now initialized by default with
- Improved
Chaplin.Router:- Early error is now thrown for
!router:route,!router:routeByNameand Chaplin.helpers.reverse methods when nothing is matched. - Removed
callbackargument from!router:routeand!router:routeByName.
- Early error is now thrown for
- Improved
Chaplin.View:- Breaking:
regionssyntax has changed to more logical. Before:regions: {'.selector': 'region'}. Now:regions: {'region': '.selector'}. We’ve made a small utility that automatically updates your code to new syntax: replace.js. Also, updatedregisterRegionmethod signature to similar. regionsoption can now be passed to constructor.insertViewnow returns inserted view.
- Breaking:
- Fix controller disposal after redirect.
- Added full lodash compatibility.
- Removed deferred mix-in (
initDeferred) support from models, collections and views. - Improved
Chaplin.ControllerandChaplin.Dispatcher:- Made
Controller#beforeActiona function. The old object form is not supported anymore. You need to usesuperlike in any other method,beforeActions won’t be merged without it. AsyncronousbeforeActions with promises are still supported. - Controllers are now disposed automatically after redirection or asynchronous before actions.
- Made
- Improved
Chaplin.Router:- Fixed bug with preserving query string in URL.
- Removed underscorizing of loaded by default controller names.
deleted_users#showwon’t longer be rewritten todeletedUsers#show. The controller name in the route is directly used as module name.
- Improved
Chaplin.View:- Added
keepElementproperty (false by default). When truthy, the view’s DOM element won’t be removed after disposal. View#disposenow calls Backbone’sView#removemethod.- Subviews are now always an array.
- Added
- Improved
Chaplin.CollectionView:- Added Backbone 1.0
Collection#setsupport.
- Added Backbone 1.0
- Improved
Chaplin.Layout:- Added inheritance from
Chaplin.View. - Renamed some methods for compat with
Chaplin.View:_registeredRegionstoglobalRegionsregisterRegiontoregisterGlobalRegionregisterRegiontoregisterGlobalRegionsunregisterRegiontounregisterGlobalRegionunregisterRegionstounregisterGlobalRegions
- Changed default
Layoutelement fromdocumenttobody. - Removed explicit
view.$el.show()/hide()for managed views. - Removed
routeproperty. Usesettings.routeLinksinstead.
- Added inheritance from
- Improved
Chaplin.utils:- Removed
underscorize.
- Removed
- Improved
Chaplin.Layout:- Added
Layout#$method, which is the same asView#$. This also fixes how regions behave in Layout.
- Added
- Improved
Chaplin.View:- The check is now done when listening to collection
disposeevent whether it really came from collection and not from its model.
- The check is now done when listening to collection
- Added
Chaplin.helperscomponent. It contains Chaplin-related functions.Chaplin.utilswill contain generic functions.helpers.reverseallows to get route URL by its name and params.
- Improved
Chaplin.Application:- Separated router initialisation and start of listening for routing.
The first one as before resides in
Application#initRouter.Application#startRouting. You need to launch both. This is breaking change and without it your app will not start routing.
- Separated router initialisation and start of listening for routing.
The first one as before resides in
- Improved
Chaplin.Controller:- All actions are now initialised with
params, route, optionsinstead ofparams, options. Newrouteargument contains information about current route (controller, action, name, path) and about previous (route.previous) andoptionsjust contain options, passed toBackbone.history.navigate. - When using redirection in actions, controller will automatically dispose redirected controller.
- All actions are now initialised with
- Improved
Chaplin.Router:- All routes now have default names in format of (controller + '#' + action).
Router#reversewill now prepend mount point.- Removed RegExp routes. Use
constraintsroute param and strings instead.
- Improved
Chaplin.Layout:- Allowed registering regions.
- Added
Layout#isExternalLinkthat is used when clicking on any event and checks if current one is application-related.
- Improved
Chaplin.View:- If
autoAttachoption is false, view will not be added to container. - Empty-selector regions are now considered as bound to root view element.
- If
- Improved overall
ViewandCollectionViewperformance for common cases. - Improved internal API:
- Renamed
matchRouteglobal event torouter:match - Renamed
startupControllerglobal event todispatcher:dispatch - Changed signatures of many
Dispatchermethods, they now passroutetoo.
- Renamed
- Added support of regions and regions composition with
Chaplin.Composer. Composer grants the ability for views (and related data) to be persisted beyond one controller action. - Improved
Chaplin.Controller:- Query string params are now passed to controllers (a feature removed from Backbone 0.9.9).
- Controller actions will now receive an
optionshash as second argument, that containspath,previousControllerNameand routing options. Previously, the second argument was just apreviousControllerNamestring. - Fixed
Controller#redirectTosignature (url, options). Controller#disposewill now unbind all events bound bylistenTomethod.
- Improved
Chaplin.Dispatcher:- Stop waiting for a Promise returned by a before action when another route is dispatched or the same is dispatched again.
- Improved
Chaplin.Router:- The
paramsandoptionsobjects are copied instead of changed to prevent conflicts. If you passparamsandoptionsalong with the!router:routeevent, the controller action will receive a copy of them. Same forDispatcher. - Fixed
rootoption. - Fixed route reversals on empty patterns (for example, the top-level route).
- The
- Improved
Chaplin.Collection:Collection#disposewill now unbind all events bound bylistenTomethod.- Removed
Collection#addAtomicas it was barely used.
- Improved
Chaplin.Model:Model#serializecan be overridden onBackbone.Models. Chaplin will use it, if available, andModel#toJSONif not.Model#disposewill now unbind all events bound bylistenTomethod.- Improved time complexity of
Model#serializefrom O(n) to amortized O(1).
- Improved
Chaplin.utils:- Added
utils.getAllPropertyVersionsthat allows to gather all property versions from object’s prototypes. - Added
utils.escapeRegExpthat escapes all regular expression characters in string. - Removed
utils.wrapMethod.
- Added
- Improved
Chaplin.View:- Added
View#listenproperty that allows to declaratively listen to model / collection / mediator / view events. Just like Backbone’sView#events, which is only for DOM events. - Added new
autoAttachoption which determines whether view should be automatically attached to DOM after render. - Renamed
View#afterRendertoView#attach. - Removed
View#afterInitialize. - Removed
View#pass. Please use stickit instead for advanced model-view binding. - Switched to
$el.toggle()instead of manual CSSdisplaysetting. Which means non-block elements will behave correctly. - Switched to
Backbone.$reference for DOM manipulation. This will automatically use jQuery, Zepto or Ender as DOM library. - Early error is now thrown when
View#eventsis a function.
- Added
- Improved
Chaplin.CollectionView:- Renamed
CollectionView#itemsResettedtoCollectionView#itemsReset. - Renamed
CollectionView#getViewtoCollectionView#initItemView. - Renamed
CollectionView#showHideFallbacktoCollectionView#toggleFallback. - Renamed
CollectionView#showHideLoadingIndicatortoCollectionView#toggleLoadingIndicator. - Removed
CollectionView#renderAndInsertItem. - Item views will now be called with
autoRender: false, which prevents rendering them twice. - Item views will now emit
addedToParentevent instead ofaddedToDOMwhen they are appended to collection view. - Optimised performance by not calling jQuery / Zepto
css/animatewhen animations are disabled.
- Renamed
- Updated required Backbone version to 0.9.9+.
- Improved
Chaplin.Collection:- Removed
Collection#updatesince this function is now provided by Backbone itself (Collection#updatein Backbone < 1.0,Collection#setin Backbone >= 1.0). Thedeepoption is now calledmergeand it defaults to true.
- Removed
- Improved
Chaplin.Controller:- Added Rails-like before action filters to
Controllers. - Added
Controller#redirectToRoutewhich works likeController#redirectTo, but accepts route name instead of URL. - Added flexible
Controller#adjustTitlemethod which sets window title. - Added
Backbone.Eventsmix-in. - Removed
Controller#titleandController#historyURL. - Removed ability of redirecting to standalone controllers and action names
in
Controller#redirectTo.
- Added Rails-like before action filters to
- Improved
Chaplin.Router:- Added support for named routes.
- Added new global
!router:routeByNameevent, which allows to navigate to some route by its reverse name. - Added new global
!router:reverseevent, which allows to get URL of route by its name. - Added
namesoption toRouter#match, which allows to name route’s regular expression matches. - Removed global
!startupControllerevent.
- Improved
Chaplin.View:- Removed
View#modelBind,View#modelUnbindandView#modelUnbindAll, since Backbone now implements superiorEvents.listenToAPI. - Chaplin will now fix incorrect inheritance of view DOM events,
bound in declarative manner (with
eventshash). - Moved
View#wrapMethodtoChaplin.utils.wrapMethod. View#disposewill now throw an error ifView#initializewas called withoutsuper.
- Removed
- Improved
Chaplin.CollectionView:CollectionView#getTemplateDatano longer returnsitemsproperty, which increases performance.
- Router options are now allowed to be passed in many places.
New signatures are:
!router:routeglobal event: path, options, callback (old sig is supported too)Dispatcher#matchRoute: route, params, optionsController#redirectTo: path or (controllerName, action, params, options)
- Improved and stabilized codebase.
- Moved
Chaplin.SubscribertoChaplin.EventBroker, which now mixinspublishEventmethod to children. - Added
Chaplin.Delayer, which sets unique and named timeouts and intervals so they can be cleared afterwards when disposing objects. - Added
autoRenderoption toChaplin.CollectionView, likeChaplin.View. Defaults to true, replaces oldrenderoption. - Added
serializemethod to collections - Removed
CollectionView#viewsByCidandCollectionView#removeViewin favor of consistentView#subviewandView#removeSubview. - Removed
CollectionView#initSyncMachine. - Removed
trigger,onandoffmethods fromChaplin.mediator. - Allowed passing of multiple event types to
View#delegate. - Made various aspects of
Chaplin.Layoutconfigurable.
- A lot of various global changes.
- Added tests for all components.
- Chaplin now can be used as a standalone library.
- Bug fix: In CollectionView, get the correct item position when rendering the item view. Fixes the rendering of sorted Collections. Before the fix, the item views might have been displayed in the wrong order. (@rendez)
- Fixed correct unsubscribing of global handlers when disposing a collection.
- The codebase now uses consistent code style (@paulmillr).
- Initial release.