Skip to content

Commit

Permalink
Bump and build v2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
samccone committed Jul 18, 2014
1 parent 97f9fa6 commit 2ad7d7c
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
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.0.2",
"version": "2.0.3",
"keywords": [
"backbone",
"framework",
Expand Down
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### v2.0.3 [view commit logs](https://github.com/marionettejs/backbone.marionette/compare/v2.0.2...v2.0.3)

* Bug Fixes

* Fixed an issue where `before:show` was not triggered on a view's behavior when shown within a region.

* Destroying a view outside of its region will now cause the region to remove its reference to that view.

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

* Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "backbone.marionette",
"description": "Make your Backbone.js apps dance!",
"version": "2.0.2",
"version": "2.0.3",
"repo": "marionettejs/backbone.marionette",
"main": "lib/core/amd/backbone.marionette.js",
"keywords": [
Expand Down
44 changes: 34 additions & 10 deletions lib/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v2.0.2
// v2.0.3
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -489,7 +489,7 @@

var Marionette = Backbone.Marionette = {};

Marionette.VERSION = '2.0.2';
Marionette.VERSION = '2.0.3';

Marionette.noConflict = function() {
root.Marionette = previousMarionette;
Expand Down Expand Up @@ -887,7 +887,7 @@

});

/* jshint maxcomplexity: 10, maxstatements: 27 */
/* jshint maxcomplexity: 10, maxstatements: 29 */

// Region
// ------
Expand Down Expand Up @@ -1043,14 +1043,26 @@
var _shouldShowView = isDifferentView || forceShow;

if (_shouldShowView) {

// We need to listen for if a view is destroyed
// in a way other than through the region.
// If this happens we need to remove the reference
// to the currentView since once a view has been destroyed
// we can not reuse it.
view.once('destroy', _.bind(this.empty, this));
view.render();

if (isChangingView) {
this.triggerMethod('before:swap', view);
}

this.triggerMethod('before:show', view);
this.triggerMethod.call(view, 'before:show');

if (_.isFunction(view.triggerMethod)) {
view.triggerMethod('before:show');
} else {
this.triggerMethod.call(view, 'before:show');
}

this.attachHtml(view);
this.currentView = view;
Expand Down Expand Up @@ -1102,19 +1114,31 @@
// current view, it does nothing and returns immediately.
empty: function() {
var view = this.currentView;
if (!view || view.isDestroyed) { return; }

this.triggerMethod('before:empty', view);

// call 'destroy' or 'remove', depending on which is found
if (view.destroy) { view.destroy(); }
else if (view.remove) { view.remove(); }
// If there is no view in the region
// we should not remove anything
if (!view) { return; }

this.triggerMethod('before:empty', view);
this._destroyView();
this.triggerMethod('empty', view);

// Remove region pointer to the currentView
delete this.currentView;
},

// call 'destroy' or 'remove', depending on which is found
// on the view (if showing a raw Backbone view or a Marionette View)
_destroyView: function() {
var view = this.currentView;

if (view.destroy && !view.isDestroyed) {
view.destroy();
} else if (view.remove) {
view.remove();
}
},

// Attach an existing view to the region. This
// will not call `render` or `onShow` for the new view,
// and will not replace the current HTML for the `el`
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.

44 changes: 34 additions & 10 deletions lib/core/backbone.marionette.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// MarionetteJS (Backbone.Marionette)
// ----------------------------------
// v2.0.2
// v2.0.3
//
// Copyright (c)2014 Derick Bailey, Muted Solutions, LLC.
// Distributed under MIT license
Expand Down Expand Up @@ -30,7 +30,7 @@

var Marionette = Backbone.Marionette = {};

Marionette.VERSION = '2.0.2';
Marionette.VERSION = '2.0.3';

Marionette.noConflict = function() {
root.Marionette = previousMarionette;
Expand Down Expand Up @@ -426,7 +426,7 @@

});

/* jshint maxcomplexity: 10, maxstatements: 27 */
/* jshint maxcomplexity: 10, maxstatements: 29 */

// Region
// ------
Expand Down Expand Up @@ -582,14 +582,26 @@
var _shouldShowView = isDifferentView || forceShow;

if (_shouldShowView) {

// We need to listen for if a view is destroyed
// in a way other than through the region.
// If this happens we need to remove the reference
// to the currentView since once a view has been destroyed
// we can not reuse it.
view.once('destroy', _.bind(this.empty, this));
view.render();

if (isChangingView) {
this.triggerMethod('before:swap', view);
}

this.triggerMethod('before:show', view);
this.triggerMethod.call(view, 'before:show');

if (_.isFunction(view.triggerMethod)) {
view.triggerMethod('before:show');
} else {
this.triggerMethod.call(view, 'before:show');
}

this.attachHtml(view);
this.currentView = view;
Expand Down Expand Up @@ -641,19 +653,31 @@
// current view, it does nothing and returns immediately.
empty: function() {
var view = this.currentView;
if (!view || view.isDestroyed) { return; }

this.triggerMethod('before:empty', view);

// call 'destroy' or 'remove', depending on which is found
if (view.destroy) { view.destroy(); }
else if (view.remove) { view.remove(); }
// If there is no view in the region
// we should not remove anything
if (!view) { return; }

this.triggerMethod('before:empty', view);
this._destroyView();
this.triggerMethod('empty', view);

// Remove region pointer to the currentView
delete this.currentView;
},

// call 'destroy' or 'remove', depending on which is found
// on the view (if showing a raw Backbone view or a Marionette View)
_destroyView: function() {
var view = this.currentView;

if (view.destroy && !view.isDestroyed) {
view.destroy();
} else if (view.remove) {
view.remove();
}
},

// Attach an existing view to the region. This
// will not call `render` or `onShow` for the new view,
// and will not replace the current HTML for the `el`
Expand Down
2 changes: 1 addition & 1 deletion lib/core/backbone.marionette.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/backbone.marionette.min.js

Large diffs are not rendered by default.

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

0 comments on commit 2ad7d7c

Please sign in to comment.