Skip to content

Commit

Permalink
Merge pull request #762 from marionettejs/sjs/fix-default-view-options
Browse files Browse the repository at this point in the history
[fix] default view options should be {} and not undefined
  • Loading branch information
samccone committed Oct 30, 2013
2 parents 59ff85d + 0c8adfa commit f586a80
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions spec/javascripts/view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,20 @@ describe("base view", function(){
});
});

describe("constructing a view with default options", function(){
var view = Marionette.ItemView.extend();

it("should take and store view options", function() {
var viewInstance = new view({"Guybrush": "Island"});
expect(viewInstance.options.Guybrush).toBe("Island");
});

it("should have an empty hash of options by default", function() {
var viewInstance = new view;
expect(typeof(viewInstance.options.Guybrush)).toBe("undefined");
});
});

describe("when closing a view that is already closed", function(){
var close, view;

Expand Down
2 changes: 1 addition & 1 deletion src/marionette.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Marionette.View = Backbone.View.extend({

var args = Array.prototype.slice.apply(arguments);
Backbone.View.prototype.constructor.apply(this, args);
this.options = options;
this.options = options || {};

Marionette.MonitorDOMRefresh(this);
this.listenTo(this, "show", this.onShowCalled, this);
Expand Down

0 comments on commit f586a80

Please sign in to comment.