diff --git a/backbone.js b/backbone.js index 1074d7fc..ec79a532 100644 --- a/backbone.js +++ b/backbone.js @@ -985,7 +985,7 @@ // if an existing element is not provided... var View = Backbone.View = function(options) { this.cid = _.uniqueId('view'); - this._configure(options || {}); + options = this._configure(options || {}); this._ensureElement(); this.initialize.apply(this, arguments); this.delegateEvents(); @@ -1089,7 +1089,7 @@ _configure: function(options) { if (this.options) options = _.extend({}, _.result(this, 'options'), options); _.extend(this, _.pick(options, viewOptions)); - this.options = options; + return options; }, // Ensure that the View has a DOM element to render into. diff --git a/test/view.js b/test/view.js index 58a87718..755ba797 100644 --- a/test/view.js +++ b/test/view.js @@ -14,13 +14,10 @@ $(document).ready(function() { }); - test("constructor", 6, function() { + test("constructor", 3, function() { equal(view.el.id, 'test-view'); equal(view.el.className, 'test-view'); equal(view.el.other, void 0); - equal(view.options.id, 'test-view'); - equal(view.options.className, 'test-view'); - equal(view.options.other, 'non-special-option'); }); test("jQuery", 1, function() { @@ -156,28 +153,22 @@ $(document).ready(function() { strictEqual(new View().el.id, 'id'); }); - test("with options function", 3, function() { - var View1 = Backbone.View.extend({ + test("with options function", 2, function() { + + var View = Backbone.View.extend({ + options: function() { - return { - title: 'title1', - acceptText: 'confirm' - }; + return {title: 'title'}; + }, + + initialize: function(options) { + strictEqual(options.title, 'title'); + strictEqual(options.fixed, true); } + }); - var View2 = View1.extend({ - options: function() { - return _.extend(View1.prototype.options.call(this), { - title: 'title2', - fixed: true - }); - } - }); - - strictEqual(new View2().options.title, 'title2'); - strictEqual(new View2().options.acceptText, 'confirm'); - strictEqual(new View2().options.fixed, true); + new View({fixed: true}); }); test("with attributes", 2, function() {