Skip to content

Commit

Permalink
_WidgetsInTemplateMixin: remove support for _earlyTemplatedStartup et…
Browse files Browse the repository at this point in the history
…c., refs #4
  • Loading branch information
wkeese committed Feb 27, 2013
1 parent 937240b commit a03babb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 531 deletions.
64 changes: 24 additions & 40 deletions _WidgetsInTemplateMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,36 @@ define([
// summary:
// Mixin to supplement _TemplatedMixin when template contains widgets

// _earlyTemplatedStartup: Boolean
// A fallback to preserve the 1.0 - 1.3 behavior of children in
// templates having their startup called before the parent widget
// fires postCreate. Defaults to 'false', causing child widgets to
// have their .startup() called immediately before a parent widget
// .startup(), but always after the parent .postCreate(). Set to
// 'true' to re-enable to previous, arguably broken, behavior.
_earlyTemplatedStartup: false,

// widgetsInTemplate: [protected] Boolean
// Should we parse the template to find widgets that might be
// declared in markup inside it? (Remove for 2.0 and assume true)
widgetsInTemplate: true,

// contextRequire: Function
// Used to provide a context require to the dojo/parser in order to be
// able to use relative MIDs (e.g. `./Widget`) in the widget's template.
contextRequire: null,

_beforeFillContent: function(){
if(this.widgetsInTemplate){
// Before copying over content, instantiate widgets in template
var node = this.domNode;

parser.parse(node, {
noStart: true,
template: true,
inherited: {dir: this.dir, lang: this.lang, textDir: this.textDir},
propsThis: this, // so data-dojo-props of widgets in the template can reference "this" to refer to me
contextRequire: this.contextRequire,
scope: "dojo" // even in multi-version mode templates use dojoType/data-dojo-type
}).then(lang.hitch(this, function(widgets){
this._startupWidgets = widgets;

// _WidgetBase::destroy() will destroy any supporting widgets under this.domNode.
// If we wanted to, we could call this.own() on anything in this._startupWidgets that was moved outside
// of this.domNode (like Dialog, which is moved to <body>).
this._attachTemplateNodes(widgets, function(n,p){
return n[p];
});
}));

if(!this._startupWidgets){
throw new Error(this.declaredClass + ": parser returned unfilled promise (probably waiting for module auto-load), " +
"unsupported by _WidgetsInTemplateMixin. Must pre-load all supporting widgets before instantiation.");
}
// Before copying over content, instantiate widgets in template
var node = this.domNode;

parser.parse(node, {
noStart: true,
template: true,
inherited: {dir: this.dir, lang: this.lang, textDir: this.textDir},
propsThis: this, // so data-dojo-props of widgets in the template can reference "this" to refer to me
contextRequire: this.contextRequire,
scope: "dojo" // even in multi-version mode templates use dojoType/data-dojo-type
}).then(lang.hitch(this, function(widgets){
this._startupWidgets = widgets;

// _WidgetBase::destroy() will destroy any supporting widgets under this.domNode.
// If we wanted to, we could call this.own() on anything in this._startupWidgets that was moved outside
// of this.domNode (like Dialog, which is moved to <body>).
this._attachTemplateNodes(widgets, function(n,p){
return n[p];
});
}));

if(!this._startupWidgets){
throw new Error(this.declaredClass + ": parser returned unfilled promise (probably waiting for module auto-load), " +
"unsupported by _WidgetsInTemplateMixin. Must pre-load all supporting widgets before instantiation.");
}
},

Expand Down
Loading

0 comments on commit a03babb

Please sign in to comment.