mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
make .parented() work so #each can use it
The problem was we don't currently chain callbacks like rendered and parented when a class and superclass have different implementations. The plumbing here is all rather arbitrary, considering our inheritance model is not finalized (and we may even do away with it, a la React) and "parented" is at best an undocumented but usable peer to "rendered". Renamed the "parented" signal from DomRange to Component "notifyParented".
This commit is contained in:
@@ -298,7 +298,7 @@ _extend(UI.Component, {
|
||||
|
||||
// XXX we don't really want this to be a user-visible callback,
|
||||
// it's just a particular signal we need from DomRange.
|
||||
UI.Component.parented = function () {
|
||||
UI.Component.notifyParented = function () {
|
||||
var self = this;
|
||||
for (var comp = self; comp; comp = comp._super) {
|
||||
var events = (comp.hasOwnProperty('_events') && comp._events) || null;
|
||||
@@ -336,10 +336,26 @@ UI.Component.parented = function () {
|
||||
});
|
||||
}
|
||||
|
||||
// XXX think about this callback's timing
|
||||
var updatedTemplateInstance = false;
|
||||
|
||||
// XXX this is an undocumented callback
|
||||
if (self.parented) {
|
||||
Deps.nonreactive(function () {
|
||||
if (! updatedTemplateInstance) {
|
||||
updateTemplateInstance(self);
|
||||
updatedTemplateInstance = true;
|
||||
}
|
||||
self.parented.call(self.templateInstance);
|
||||
});
|
||||
}
|
||||
|
||||
// XXX fix this callback's timing
|
||||
if (self.rendered) {
|
||||
Deps.nonreactive(function () {
|
||||
updateTemplateInstance(self);
|
||||
if (! updatedTemplateInstance) {
|
||||
updateTemplateInstance(self);
|
||||
updatedTemplateInstance = true;
|
||||
}
|
||||
self.rendered.call(self.templateInstance);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,10 +114,8 @@ var rangeParented = function (range) {
|
||||
});
|
||||
}
|
||||
|
||||
// XXX is this a real callback? what about chaining? etc.
|
||||
if (range.component.parented) {
|
||||
range.component.parented();
|
||||
}
|
||||
if (range.component.notifyParented)
|
||||
range.component.notifyParented();
|
||||
|
||||
// recurse on member ranges
|
||||
var members = range.members;
|
||||
|
||||
@@ -6,8 +6,7 @@ UI.Each = Component.extend({
|
||||
this.sequence = this.data;
|
||||
this.data = undefined;
|
||||
},
|
||||
// xcxc -> parented
|
||||
rendered: function () {
|
||||
parented: function () {
|
||||
var self = this.__component__;
|
||||
|
||||
var range = self.dom;
|
||||
|
||||
Reference in New Issue
Block a user