From 90650395e25e65160347392a83d210c2ed6f4bcb Mon Sep 17 00:00:00 2001 From: Romain Dardour Date: Fri, 22 Feb 2013 15:49:52 +0100 Subject: [PATCH 1/2] Allow default options hash for widgets --- lib/ext/widgets.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ext/widgets.js b/lib/ext/widgets.js index 01a3457..2a6e21c 100644 --- a/lib/ext/widgets.js +++ b/lib/ext/widgets.js @@ -23,11 +23,11 @@ define('aura/ext/widgets', function() { * @param {Object} options the options to init the widget... */ function Widget(options) { - this.options = options; + this.options = _.defaults(options || {}, this.options || {}); this._ref = options._ref; this.$el = core.dom.find(options.el); - this.initialize.call(this, options); + this.initialize.call(this, this.options); return this; } From 26e40c35e964428e68ff3593d84edb5f12bac519 Mon Sep 17 00:00:00 2001 From: Stephane Bellity Date: Fri, 8 Mar 2013 15:59:36 +0100 Subject: [PATCH 2/2] Adding specs for default options --- lib/ext/widgets.js | 1 + spec/lib/ext/widgets_spec.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/ext/widgets.js b/lib/ext/widgets.js index 2a6e21c..dc29493 100644 --- a/lib/ext/widgets.js +++ b/lib/ext/widgets.js @@ -5,6 +5,7 @@ define('aura/ext/widgets', function() { return function(app) { var core = app.core; + var _ = app.core.util._; core.Widgets = core.Widgets || {}; var ownProp = function(obj, key) { diff --git a/spec/lib/ext/widgets_spec.js b/spec/lib/ext/widgets_spec.js index ce0faf9..df73afd 100644 --- a/spec/lib/ext/widgets_spec.js +++ b/spec/lib/ext/widgets_spec.js @@ -68,6 +68,10 @@ define(['aura/aura', 'aura/ext/widgets'], function (aura, ext) { var app, options; var myAltWidget = makeSpyWidget('alt_namespace', { + options: { + foo: 'bar', + another: 'toutafait' + }, initialize: function () { options = this.options; } @@ -77,6 +81,7 @@ define(['aura/aura', 'aura/ext/widgets'], function (aura, ext) { var markup = '