Skip to content

Commit

Permalink
Bump and build 2.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfalgout committed Nov 18, 2015
1 parent 77cab46 commit 4d017f7
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 75 deletions.
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -3,7 +3,7 @@
"description": "Make your Backbone.js apps dance with a composite application architecture!",
"homepage": "http://marionettejs.org",
"main": "./lib/core/backbone.marionette.js",
"version": "2.4.3",
"version": "2.4.4",
"keywords": [
"backbone",
"framework",
Expand Down
15 changes: 14 additions & 1 deletion changelog.md
@@ -1,3 +1,17 @@
### v2.4.4 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.3...v2.4.4)

#### Fixes

* `Region#empty` will return the region instance whether or not it has a current view.
* `CollectionView#reorder` will now correctly respect any set filter.
* Fixed `childEvents` failing to trigger during showing a view in a region.
* Stop deleting the `currentView._parent` if showing the same view in a region.

#### Misc

* `LayoutView#showChildView` new `options` argument passed to underlying `Region#show` to enable full `show` functionality.
* Added support for passing down arguments to `Object#destroy`.

### v2.4.3 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.4.2...v2.4.3)

#### Fixes
Expand All @@ -18,7 +32,6 @@

#### Misc

* `LayoutView#showChildView` new `options` argument passed to underlying `Region#show` to enable full `show` functionality.
* Allow `Application` to be initialized with multiple arguments for consistency with earlier releases.
* 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.
* Bumped Backbone dependency to 1.2.3
Expand Down
2 changes: 1 addition & 1 deletion component.json
@@ -1,7 +1,7 @@
{
"name": "backbone.marionette",
"description": "Make your Backbone.js apps dance!",
"version": "2.4.3",
"version": "2.4.4",
"repo": "marionettejs/backbone.marionette",
"main": "lib/core/backbone.marionette.js",
"keywords": [
Expand Down
76 changes: 44 additions & 32 deletions lib/backbone.marionette.js
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v2.4.3
// v2.4.4
//
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -489,7 +489,7 @@

var Marionette = Backbone.Marionette = {};

Marionette.VERSION = '2.4.3';
Marionette.VERSION = '2.4.4';

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

destroy: function() {
this.triggerMethod('before:destroy');
this.triggerMethod('destroy');
destroy: function(options) {
options = options || {};

this.triggerMethod('before:destroy', options);
this.triggerMethod('destroy', options);
this.stopListening();

return this;
Expand Down Expand Up @@ -1135,9 +1137,12 @@
// we can not reuse it.
view.once('destroy', this.empty, this);

this._renderView(view);

// make this region the view's parent,
// It's important that this parent binding happens before rendering
// so that any events the child may trigger during render can also be
// triggered on the child's ancestor views
view._parent = this;
this._renderView(view);

if (isChangingView) {
this.triggerMethod('before:swap', view, this, options);
Expand Down Expand Up @@ -1269,7 +1274,7 @@
var preventDestroy = !!emptyOptions.preventDestroy;
// If there is no view in the region
// we should not remove anything
if (!view) { return; }
if (!view) { return this; }

view.off('destroy', this.empty, this);
this.triggerMethod('before:empty', view);
Expand Down Expand Up @@ -1963,6 +1968,10 @@

// call the parent view's childEvents handler
var childEvents = Marionette.getOption(layoutView, 'childEvents');

// since childEvents can be an object or a function use Marionette._getValue
// to handle the abstaction for us.
childEvents = Marionette._getValue(childEvents, layoutView);
var normalizedChildEvents = layoutView.normalizeMethods(childEvents);

if (normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) {
Expand All @@ -1988,26 +1997,17 @@
}, children);
},

// Internal utility for building an ancestor
// view tree list.
_getAncestors: function() {
var ancestors = [];
// Walk the _parent tree until we find a layout view (if one exists).
// Returns the parent layout view hierarchically closest to this view.
_parentLayoutView: function() {
var parent = this._parent;

while (parent) {
ancestors.push(parent);
if (parent instanceof Marionette.LayoutView) {
return parent;
}
parent = parent._parent;
}

return ancestors;
},

// Returns the containing parent view.
_parentLayoutView: function() {
var ancestors = this._getAncestors();
return _.find(ancestors, function(parent) {
return parent instanceof Marionette.LayoutView;
});
},

// Imports the "normalizeMethods" to transform hashes of
Expand Down Expand Up @@ -2306,27 +2306,38 @@
reorder: function() {
var children = this.children;
var models = this._filteredSortedModels();
var modelsChanged = _.find(models, function(model) {
var anyModelsAdded = _.some(models, function(model) {
return !children.findByModel(model);
});

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

// find the views that were children before but arent in this new ordering
var filteredOutViews = children.filter(function(view) {
return !_.contains(elsToReorder, view.el);
});

this.triggerMethod('before:reorder');

// since append moves elements that are already in the DOM,
// appending the elements will effectively reorder them
this.triggerMethod('before:reorder');
this._appendReorderedChildren(els);
this._appendReorderedChildren(elsToReorder);

// remove any views that have been filtered out
_.each(filteredOutViews, this.removeChildView, this);
this.checkEmpty();

this.triggerMethod('reorder');
}
},
Expand Down Expand Up @@ -3093,8 +3104,9 @@
return Marionette.ItemView.prototype.destroy.apply(this, arguments);
},

showChildView: function(regionName, view) {
return this.getRegion(regionName).show(view);
showChildView: function(regionName, view, options) {
var region = this.getRegion(regionName);
return region.show.apply(region, _.rest(arguments));
},

getChildView: function(regionName) {
Expand Down
2 changes: 1 addition & 1 deletion lib/backbone.marionette.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/backbone.marionette.min.js

Large diffs are not rendered by default.

76 changes: 44 additions & 32 deletions lib/core/backbone.marionette.js
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v2.4.3
// v2.4.4
//
// Copyright (c)2015 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -31,7 +31,7 @@

var Marionette = Backbone.Marionette = {};

Marionette.VERSION = '2.4.3';
Marionette.VERSION = '2.4.4';

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

destroy: function() {
this.triggerMethod('before:destroy');
this.triggerMethod('destroy');
destroy: function(options) {
options = options || {};

this.triggerMethod('before:destroy', options);
this.triggerMethod('destroy', options);
this.stopListening();

return this;
Expand Down Expand Up @@ -682,9 +684,12 @@
// we can not reuse it.
view.once('destroy', this.empty, this);

this._renderView(view);

// make this region the view's parent,
// It's important that this parent binding happens before rendering
// so that any events the child may trigger during render can also be
// triggered on the child's ancestor views
view._parent = this;
this._renderView(view);

if (isChangingView) {
this.triggerMethod('before:swap', view, this, options);
Expand Down Expand Up @@ -816,7 +821,7 @@
var preventDestroy = !!emptyOptions.preventDestroy;
// If there is no view in the region
// we should not remove anything
if (!view) { return; }
if (!view) { return this; }

view.off('destroy', this.empty, this);
this.triggerMethod('before:empty', view);
Expand Down Expand Up @@ -1510,6 +1515,10 @@

// call the parent view's childEvents handler
var childEvents = Marionette.getOption(layoutView, 'childEvents');

// since childEvents can be an object or a function use Marionette._getValue
// to handle the abstaction for us.
childEvents = Marionette._getValue(childEvents, layoutView);
var normalizedChildEvents = layoutView.normalizeMethods(childEvents);

if (normalizedChildEvents && _.isFunction(normalizedChildEvents[eventName])) {
Expand All @@ -1535,26 +1544,17 @@
}, children);
},

// Internal utility for building an ancestor
// view tree list.
_getAncestors: function() {
var ancestors = [];
// Walk the _parent tree until we find a layout view (if one exists).
// Returns the parent layout view hierarchically closest to this view.
_parentLayoutView: function() {
var parent = this._parent;

while (parent) {
ancestors.push(parent);
if (parent instanceof Marionette.LayoutView) {
return parent;
}
parent = parent._parent;
}

return ancestors;
},

// Returns the containing parent view.
_parentLayoutView: function() {
var ancestors = this._getAncestors();
return _.find(ancestors, function(parent) {
return parent instanceof Marionette.LayoutView;
});
},

// Imports the "normalizeMethods" to transform hashes of
Expand Down Expand Up @@ -1853,27 +1853,38 @@
reorder: function() {
var children = this.children;
var models = this._filteredSortedModels();
var modelsChanged = _.find(models, function(model) {
var anyModelsAdded = _.some(models, function(model) {
return !children.findByModel(model);
});

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

// find the views that were children before but arent in this new ordering
var filteredOutViews = children.filter(function(view) {
return !_.contains(elsToReorder, view.el);
});

this.triggerMethod('before:reorder');

// since append moves elements that are already in the DOM,
// appending the elements will effectively reorder them
this.triggerMethod('before:reorder');
this._appendReorderedChildren(els);
this._appendReorderedChildren(elsToReorder);

// remove any views that have been filtered out
_.each(filteredOutViews, this.removeChildView, this);
this.checkEmpty();

this.triggerMethod('reorder');
}
},
Expand Down Expand Up @@ -2640,8 +2651,9 @@
return Marionette.ItemView.prototype.destroy.apply(this, arguments);
},

showChildView: function(regionName, view) {
return this.getRegion(regionName).show(view);
showChildView: function(regionName, view, options) {
var region = this.getRegion(regionName);
return region.show.apply(region, _.rest(arguments));
},

getChildView: function(regionName) {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/backbone.marionette.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/core/backbone.marionette.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "backbone.marionette",
"description": "Make your Backbone.js apps dance!",
"version": "2.4.3",
"version": "2.4.4",
"homepage": "https://github.com/marionettejs/backbone.marionette",
"main": "lib/core/backbone.marionette.js",
"keywords": [
Expand Down

0 comments on commit 4d017f7

Please sign in to comment.