Skip to content

Commit 11dc551

Browse files
paulfalgoutahumphreys87
authored andcommitted
Bump and build 2.4.4
1 parent a285b7c commit 11dc551

10 files changed

+112
-75
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Make your Backbone.js apps dance with a composite application architecture!",
44
"homepage": "http://marionettejs.org",
55
"main": "./lib/core/backbone.marionette.js",
6-
"version": "2.4.3",
6+
"version": "2.4.4",
77
"keywords": [
88
"backbone",
99
"framework",

changelog.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
### v2.4.4 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.3...v2.4.4)
2+
3+
#### Fixes
4+
5+
* `Region#empty` will return the region instance whether or not it has a current view.
6+
* `CollectionView#reorder` will now correctly respect any set filter.
7+
* Fixed `childEvents` failing to trigger during showing a view in a region.
8+
* Stop deleting the `currentView._parent` if showing the same view in a region.
9+
10+
#### Misc
11+
12+
* `LayoutView#showChildView` new `options` argument passed to underlying `Region#show` to enable full `show` functionality.
13+
* Added support for passing down arguments to `Object#destroy`.
14+
115
### v2.4.3 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.2...v2.4.3)
216

317
#### Fixes
@@ -18,7 +32,6 @@
1832

1933
#### Misc
2034

21-
* `LayoutView#showChildView` new `options` argument passed to underlying `Region#show` to enable full `show` functionality.
2235
* Allow `Application` to be initialized with multiple arguments for consistency with earlier releases.
2336
* More comprehensive support for Backbone child views, including a more rigorous test suite and support for `render`, `destroy`, and `dom:refresh` lifecycle events when shown by CollectionViews or LayoutViews/Regions.
2437
* Bumped Backbone dependency to 1.2.3

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "backbone.marionette",
33
"description": "Make your Backbone.js apps dance!",
4-
"version": "2.4.3",
4+
"version": "2.4.4",
55
"repo": "marionettejs/backbone.marionette",
66
"main": "lib/core/backbone.marionette.js",
77
"keywords": [

lib/backbone.marionette.js

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// MarionetteJS (Backbone.Marionette)
22
// ----------------------------------
3-
// v2.4.3
3+
// v2.4.4
44
//
55
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
66
// Distributed under MIT license
@@ -489,7 +489,7 @@
489489

490490
var Marionette = Backbone.Marionette = {};
491491

492-
Marionette.VERSION = '2.4.3';
492+
Marionette.VERSION = '2.4.4';
493493

494494
Marionette.noConflict = function() {
495495
root.Marionette = previousMarionette;
@@ -1019,9 +1019,11 @@
10191019
//this is a noop method intended to be overridden by classes that extend from this base
10201020
initialize: function() {},
10211021

1022-
destroy: function() {
1023-
this.triggerMethod('before:destroy');
1024-
this.triggerMethod('destroy');
1022+
destroy: function(options) {
1023+
options = options || {};
1024+
1025+
this.triggerMethod('before:destroy', options);
1026+
this.triggerMethod('destroy', options);
10251027
this.stopListening();
10261028

10271029
return this;
@@ -1135,9 +1137,12 @@
11351137
// we can not reuse it.
11361138
view.once('destroy', this.empty, this);
11371139

1138-
this._renderView(view);
1139-
1140+
// make this region the view's parent,
1141+
// It's important that this parent binding happens before rendering
1142+
// so that any events the child may trigger during render can also be
1143+
// triggered on the child's ancestor views
11401144
view._parent = this;
1145+
this._renderView(view);
11411146

11421147
if (isChangingView) {
11431148
this.triggerMethod('before:swap', view, this, options);
@@ -1269,7 +1274,7 @@
12691274
var preventDestroy = !!emptyOptions.preventDestroy;
12701275
// If there is no view in the region
12711276
// we should not remove anything
1272-
if (!view) { return; }
1277+
if (!view) { return this; }
12731278

12741279
view.off('destroy', this.empty, this);
12751280
this.triggerMethod('before:empty', view);
@@ -1963,6 +1968,10 @@
19631968

19641969
// call the parent view's childEvents handler
19651970
var childEvents = Marionette.getOption(layoutView, 'childEvents');
1971+
1972+
// since childEvents can be an object or a function use Marionette._getValue
1973+
// to handle the abstaction for us.
1974+
childEvents = Marionette._getValue(childEvents, layoutView);
19661975
var normalizedChildEvents = layoutView.normalizeMethods(childEvents);
19671976

19681977
if (normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) {
@@ -1988,26 +1997,17 @@
19881997
}, children);
19891998
},
19901999

1991-
// Internal utility for building an ancestor
1992-
// view tree list.
1993-
_getAncestors: function() {
1994-
var ancestors = [];
2000+
// Walk the _parent tree until we find a layout view (if one exists).
2001+
// Returns the parent layout view hierarchically closest to this view.
2002+
_parentLayoutView: function() {
19952003
var parent = this._parent;
19962004

19972005
while (parent) {
1998-
ancestors.push(parent);
2006+
if (parent instanceof Marionette.LayoutView) {
2007+
return parent;
2008+
}
19992009
parent = parent._parent;
20002010
}
2001-
2002-
return ancestors;
2003-
},
2004-
2005-
// Returns the containing parent view.
2006-
_parentLayoutView: function() {
2007-
var ancestors = this._getAncestors();
2008-
return _.find(ancestors, function(parent) {
2009-
return parent instanceof Marionette.LayoutView;
2010-
});
20112011
},
20122012

20132013
// Imports the "normalizeMethods" to transform hashes of
@@ -2306,27 +2306,38 @@
23062306
reorder: function() {
23072307
var children = this.children;
23082308
var models = this._filteredSortedModels();
2309-
var modelsChanged = _.find(models, function(model) {
2309+
var anyModelsAdded = _.some(models, function(model) {
23102310
return !children.findByModel(model);
23112311
});
23122312

2313-
// If the models we're displaying have changed due to filtering
2314-
// We need to add and/or remove child views
2313+
// If there are any new models added due to filtering
2314+
// We need to add child views
23152315
// So render as normal
2316-
if (modelsChanged) {
2316+
if (anyModelsAdded) {
23172317
this.render();
23182318
} else {
23192319
// get the DOM nodes in the same order as the models
2320-
var els = _.map(models, function(model, index) {
2320+
var elsToReorder = _.map(models, function(model, index) {
23212321
var view = children.findByModel(model);
23222322
view._index = index;
23232323
return view.el;
23242324
});
23252325

2326+
// find the views that were children before but arent in this new ordering
2327+
var filteredOutViews = children.filter(function(view) {
2328+
return !_.contains(elsToReorder, view.el);
2329+
});
2330+
2331+
this.triggerMethod('before:reorder');
2332+
23262333
// since append moves elements that are already in the DOM,
23272334
// appending the elements will effectively reorder them
2328-
this.triggerMethod('before:reorder');
2329-
this._appendReorderedChildren(els);
2335+
this._appendReorderedChildren(elsToReorder);
2336+
2337+
// remove any views that have been filtered out
2338+
_.each(filteredOutViews, this.removeChildView, this);
2339+
this.checkEmpty();
2340+
23302341
this.triggerMethod('reorder');
23312342
}
23322343
},
@@ -3093,8 +3104,9 @@
30933104
return Marionette.ItemView.prototype.destroy.apply(this, arguments);
30943105
},
30953106

3096-
showChildView: function(regionName, view) {
3097-
return this.getRegion(regionName).show(view);
3107+
showChildView: function(regionName, view, options) {
3108+
var region = this.getRegion(regionName);
3109+
return region.show.apply(region, _.rest(arguments));
30983110
},
30993111

31003112
getChildView: function(regionName) {

lib/backbone.marionette.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/backbone.marionette.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/backbone.marionette.js

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// MarionetteJS (Backbone.Marionette)
22
// ----------------------------------
3-
// v2.4.3
3+
// v2.4.4
44
//
55
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
66
// Distributed under MIT license
@@ -31,7 +31,7 @@
3131

3232
var Marionette = Backbone.Marionette = {};
3333

34-
Marionette.VERSION = '2.4.3';
34+
Marionette.VERSION = '2.4.4';
3535

3636
Marionette.noConflict = function() {
3737
root.Marionette = previousMarionette;
@@ -566,9 +566,11 @@
566566
//this is a noop method intended to be overridden by classes that extend from this base
567567
initialize: function() {},
568568

569-
destroy: function() {
570-
this.triggerMethod('before:destroy');
571-
this.triggerMethod('destroy');
569+
destroy: function(options) {
570+
options = options || {};
571+
572+
this.triggerMethod('before:destroy', options);
573+
this.triggerMethod('destroy', options);
572574
this.stopListening();
573575

574576
return this;
@@ -682,9 +684,12 @@
682684
// we can not reuse it.
683685
view.once('destroy', this.empty, this);
684686

685-
this._renderView(view);
686-
687+
// make this region the view's parent,
688+
// It's important that this parent binding happens before rendering
689+
// so that any events the child may trigger during render can also be
690+
// triggered on the child's ancestor views
687691
view._parent = this;
692+
this._renderView(view);
688693

689694
if (isChangingView) {
690695
this.triggerMethod('before:swap', view, this, options);
@@ -816,7 +821,7 @@
816821
var preventDestroy = !!emptyOptions.preventDestroy;
817822
// If there is no view in the region
818823
// we should not remove anything
819-
if (!view) { return; }
824+
if (!view) { return this; }
820825

821826
view.off('destroy', this.empty, this);
822827
this.triggerMethod('before:empty', view);
@@ -1510,6 +1515,10 @@
15101515

15111516
// call the parent view's childEvents handler
15121517
var childEvents = Marionette.getOption(layoutView, 'childEvents');
1518+
1519+
// since childEvents can be an object or a function use Marionette._getValue
1520+
// to handle the abstaction for us.
1521+
childEvents = Marionette._getValue(childEvents, layoutView);
15131522
var normalizedChildEvents = layoutView.normalizeMethods(childEvents);
15141523

15151524
if (normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) {
@@ -1535,26 +1544,17 @@
15351544
}, children);
15361545
},
15371546

1538-
// Internal utility for building an ancestor
1539-
// view tree list.
1540-
_getAncestors: function() {
1541-
var ancestors = [];
1547+
// Walk the _parent tree until we find a layout view (if one exists).
1548+
// Returns the parent layout view hierarchically closest to this view.
1549+
_parentLayoutView: function() {
15421550
var parent = this._parent;
15431551

15441552
while (parent) {
1545-
ancestors.push(parent);
1553+
if (parent instanceof Marionette.LayoutView) {
1554+
return parent;
1555+
}
15461556
parent = parent._parent;
15471557
}
1548-
1549-
return ancestors;
1550-
},
1551-
1552-
// Returns the containing parent view.
1553-
_parentLayoutView: function() {
1554-
var ancestors = this._getAncestors();
1555-
return _.find(ancestors, function(parent) {
1556-
return parent instanceof Marionette.LayoutView;
1557-
});
15581558
},
15591559

15601560
// Imports the "normalizeMethods" to transform hashes of
@@ -1853,27 +1853,38 @@
18531853
reorder: function() {
18541854
var children = this.children;
18551855
var models = this._filteredSortedModels();
1856-
var modelsChanged = _.find(models, function(model) {
1856+
var anyModelsAdded = _.some(models, function(model) {
18571857
return !children.findByModel(model);
18581858
});
18591859

1860-
// If the models we're displaying have changed due to filtering
1861-
// We need to add and/or remove child views
1860+
// If there are any new models added due to filtering
1861+
// We need to add child views
18621862
// So render as normal
1863-
if (modelsChanged) {
1863+
if (anyModelsAdded) {
18641864
this.render();
18651865
} else {
18661866
// get the DOM nodes in the same order as the models
1867-
var els = _.map(models, function(model, index) {
1867+
var elsToReorder = _.map(models, function(model, index) {
18681868
var view = children.findByModel(model);
18691869
view._index = index;
18701870
return view.el;
18711871
});
18721872

1873+
// find the views that were children before but arent in this new ordering
1874+
var filteredOutViews = children.filter(function(view) {
1875+
return !_.contains(elsToReorder, view.el);
1876+
});
1877+
1878+
this.triggerMethod('before:reorder');
1879+
18731880
// since append moves elements that are already in the DOM,
18741881
// appending the elements will effectively reorder them
1875-
this.triggerMethod('before:reorder');
1876-
this._appendReorderedChildren(els);
1882+
this._appendReorderedChildren(elsToReorder);
1883+
1884+
// remove any views that have been filtered out
1885+
_.each(filteredOutViews, this.removeChildView, this);
1886+
this.checkEmpty();
1887+
18771888
this.triggerMethod('reorder');
18781889
}
18791890
},
@@ -2640,8 +2651,9 @@
26402651
return Marionette.ItemView.prototype.destroy.apply(this, arguments);
26412652
},
26422653

2643-
showChildView: function(regionName, view) {
2644-
return this.getRegion(regionName).show(view);
2654+
showChildView: function(regionName, view, options) {
2655+
var region = this.getRegion(regionName);
2656+
return region.show.apply(region, _.rest(arguments));
26452657
},
26462658

26472659
getChildView: function(regionName) {

lib/core/backbone.marionette.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/backbone.marionette.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "backbone.marionette",
33
"description": "Make your Backbone.js apps dance!",
4-
"version": "2.4.3",
4+
"version": "2.4.4",
55
"homepage": "https://github.com/marionettejs/backbone.marionette",
66
"main": "lib/core/backbone.marionette.js",
77
"keywords": [

0 commit comments

Comments
 (0)