mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Make Template.instance() correct in this.autorun() in templates
A previous change decoupled "current view" from "current template instance". The code made sure to preserve "current view" explicitly within `this.autorun`, but now we need to do the same for "current template instance"
This commit is contained in:
@@ -174,9 +174,13 @@ Blaze.View.prototype.autorun = function (f, _inViewScope) {
|
||||
throw new Error("Can't call View#autorun from a Tracker Computation; try calling it from the created or rendered callback");
|
||||
}
|
||||
|
||||
var templateInstanceFunc = Blaze.Template._currentTemplateInstanceFunc;
|
||||
|
||||
var c = Tracker.autorun(function viewAutorun(c) {
|
||||
return Blaze._withCurrentView(_inViewScope || self, function () {
|
||||
return f.call(self, c);
|
||||
return Blaze.Template._withTemplateInstanceFunc(templateInstanceFunc, function () {
|
||||
return f.call(self, c);
|
||||
});
|
||||
});
|
||||
});
|
||||
self.onViewDestroyed(function () { c.stop(); });
|
||||
|
||||
Reference in New Issue
Block a user