From bee046de6437548183ad4e824172c6fcb90cbb7a Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Tue, 6 May 2014 17:47:13 -0700 Subject: [PATCH] Minor tweaks --- .../blaze-test/client/blaze-test.js | 2 +- packages/blaze/materialize.js | 24 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/unfinished/blaze-test/client/blaze-test.js b/examples/unfinished/blaze-test/client/blaze-test.js index 538970d2d7..92761e3cdc 100644 --- a/examples/unfinished/blaze-test/client/blaze-test.js +++ b/examples/unfinished/blaze-test/client/blaze-test.js @@ -156,4 +156,4 @@ outerRange.attach(document.body); // outerRange.stop(); // ``` -}); \ No newline at end of file +}); diff --git a/packages/blaze/materialize.js b/packages/blaze/materialize.js index bceb8241e1..c113dffb08 100644 --- a/packages/blaze/materialize.js +++ b/packages/blaze/materialize.js @@ -5,10 +5,10 @@ // computation). Blaze._inDummyComputation = function (f) { var ret; - Deps.autorun(function (c) { + Blaze._wrapAutorun(Deps.autorun(function (c) { c.stop(); ret = f(); - }); + })); return ret; }; @@ -26,6 +26,11 @@ Blaze.ToTextVisitor = HTML.ToTextVisitor.extend({ } }); +var ToTextController = Blaze.ToTextController = function () { + Blaze.Controller.call(this); +}; +__extends(Blaze.ToTextController, Blaze.Controller); + Blaze.toText = function (content, textMode) { if (! Deps.active) { return Blaze._inDummyComputation(function () { @@ -43,7 +48,10 @@ Blaze.toText = function (content, textMode) { var visitor = new Blaze.ToTextVisitor; visitor.textMode = textMode; - return visitor.visit(content); + var controller = (Blaze.currentController || new ToTextController); + return Blaze.withCurrentController(controller, function () { + return visitor.visit(content); + }); }; ////////////////////////////// Blaze.toHTML @@ -60,6 +68,11 @@ Blaze.ToHTMLVisitor = HTML.ToHTMLVisitor.extend({ } }); +var ToHTMLController = Blaze.ToHTMLController = function () { + Blaze.Controller.call(this); +}; +__extends(Blaze.ToHTMLController, Blaze.Controller); + // This function is mainly for server-side rendering and is not in the normal // code path for client-side rendering. Blaze.toHTML = function (content) { @@ -68,7 +81,10 @@ Blaze.toHTML = function (content) { return Blaze.toHTML(content); }); } - return (new Blaze.ToHTMLVisitor).visit(content); + var controller = (Blaze.currentController || new ToHTMLController); + return Blaze.withCurrentController(controller, function () { + return (new Blaze.ToHTMLVisitor).visit(content); + }); };