From 307b9a95041b86b4eb8fa103149cb435871acc20 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Mon, 11 Aug 2014 14:38:46 -0700 Subject: [PATCH] Make more Blaze calls private Put underscores before: ReactiveVar, InOuterTemplateScope, EventSupport, reportException, wrapCatchingExceptions, DOMMaterializer, and HTMLJSExpander --- packages/blaze/builtins.js | 16 ++++++++-------- packages/blaze/events.js | 2 +- packages/blaze/exceptions.js | 6 +++--- packages/blaze/lookup.js | 2 +- packages/blaze/materializer.js | 6 +++--- packages/blaze/reactivevar.js | 18 +++++++++--------- packages/blaze/view.js | 12 ++++++------ packages/spacebars-compiler/codegen.js | 2 +- packages/spacebars/spacebars-runtime.js | 4 ++-- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/packages/blaze/builtins.js b/packages/blaze/builtins.js index 7a47b3a7b4..05a12c4a35 100644 --- a/packages/blaze/builtins.js +++ b/packages/blaze/builtins.js @@ -7,7 +7,7 @@ Blaze._calculateCondition = function (cond) { Blaze.With = function (data, contentFunc) { var view = Blaze.View('with', contentFunc); - view.dataVar = new Blaze.ReactiveVar; + view.dataVar = new Blaze._ReactiveVar; view.onCreated(function () { if (typeof data === 'function') { @@ -24,7 +24,7 @@ Blaze.With = function (data, contentFunc) { }; Blaze.If = function (conditionFunc, contentFunc, elseFunc, _not) { - var conditionVar = new Blaze.ReactiveVar; + var conditionVar = new Blaze._ReactiveVar; var view = Blaze.View(_not ? 'unless' : 'if', function () { return conditionVar.get() ? contentFunc() : @@ -61,7 +61,7 @@ Blaze.Each = function (argFunc, contentFunc, elseFunc) { eachView.stopHandle = null; eachView.contentFunc = contentFunc; eachView.elseFunc = elseFunc; - eachView.argVar = new Blaze.ReactiveVar; + eachView.argVar = new Blaze._ReactiveVar; eachView.onCreated(function () { // We evaluate argFunc in an autorun to make sure @@ -161,15 +161,15 @@ Blaze._TemplateWith = function (argFunc, contentBlock) { var w; // This is a little messy. When we compile `{{> UI.contentBlock}}`, we - // wrap it in Blaze.InOuterTemplateScope in order to skip the intermediate + // wrap it in Blaze._InOuterTemplateScope in order to skip the intermediate // parent Views in the current template. However, when there's an argument // (`{{> UI.contentBlock arg}}`), the argument needs to be evaluated // in the original scope. There's no good order to nest - // Blaze.InOuterTemplateScope and Spacebars.TemplateWith to achieve this, + // Blaze._InOuterTemplateScope and Spacebars.TemplateWith to achieve this, // so we wrap argFunc to run it in the "original parentView" of the - // Blaze.InOuterTemplateScope. + // Blaze._InOuterTemplateScope. // - // To make this better, reconsider InOuterTemplateScope as a primitive. + // To make this better, reconsider _InOuterTemplateScope as a primitive. // Longer term, evaluate expressions in the proper lexical scope. var wrappedArgFunc = function () { var viewToEvaluateArg = null; @@ -188,7 +188,7 @@ Blaze._TemplateWith = function (argFunc, contentBlock) { return w; }; -Blaze.InOuterTemplateScope = function (templateView, contentFunc) { +Blaze._InOuterTemplateScope = function (templateView, contentFunc) { var view = Blaze.View('InOuterTemplateScope', contentFunc); var parentView = templateView.parentView; diff --git a/packages/blaze/events.js b/packages/blaze/events.js index 016aa68244..8d2ee89050 100644 --- a/packages/blaze/events.js +++ b/packages/blaze/events.js @@ -1,4 +1,4 @@ -var EventSupport = Blaze.EventSupport = {}; +var EventSupport = Blaze._EventSupport = {}; var DOMBackend = Blaze._DOMBackend; diff --git a/packages/blaze/exceptions.js b/packages/blaze/exceptions.js index a8d9317450..8f68aa9dcb 100644 --- a/packages/blaze/exceptions.js +++ b/packages/blaze/exceptions.js @@ -22,7 +22,7 @@ var debugFunc; // useful in unit tests that test error messages. Blaze._throwNextException = false; -Blaze.reportException = function (e, msg) { +Blaze._reportException = function (e, msg) { if (Blaze._throwNextException) { Blaze._throwNextException = false; throw e; @@ -42,7 +42,7 @@ Blaze.reportException = function (e, msg) { debugFunc()(msg || 'Exception caught in template:', e.stack || e.message); }; -Blaze.wrapCatchingExceptions = function (f, where) { +Blaze._wrapCatchingExceptions = function (f, where) { if (typeof f !== 'function') return f; @@ -50,7 +50,7 @@ Blaze.wrapCatchingExceptions = function (f, where) { try { return f.apply(this, arguments); } catch (e) { - Blaze.reportException(e, 'Exception in ' + where + ':'); + Blaze._reportException(e, 'Exception in ' + where + ':'); } }; }; diff --git a/packages/blaze/lookup.js b/packages/blaze/lookup.js index b581660443..8b9c678f14 100644 --- a/packages/blaze/lookup.js +++ b/packages/blaze/lookup.js @@ -21,7 +21,7 @@ var bindDataContext = function (x) { }; var wrapHelper = function (f) { - return Blaze.wrapCatchingExceptions(f, 'template helper'); + return Blaze._wrapCatchingExceptions(f, 'template helper'); }; // !!! FIX THIS COMMENT !!! diff --git a/packages/blaze/materializer.js b/packages/blaze/materializer.js index 897a7c6cd4..d276772f71 100644 --- a/packages/blaze/materializer.js +++ b/packages/blaze/materializer.js @@ -1,10 +1,10 @@ -// new Blaze.DOMMaterializer(options) +// new Blaze._DOMMaterializer(options) // // An HTML.Visitor that turns HTMLjs into DOM nodes and DOMRanges. // // Options: `parentView` -Blaze.DOMMaterializer = HTML.Visitor.extend(); -Blaze.DOMMaterializer.def({ +Blaze._DOMMaterializer = HTML.Visitor.extend(); +Blaze._DOMMaterializer.def({ visitNull: function (x, intoArray) { return intoArray; }, diff --git a/packages/blaze/reactivevar.js b/packages/blaze/reactivevar.js index e1c3195272..1ab9dbb559 100644 --- a/packages/blaze/reactivevar.js +++ b/packages/blaze/reactivevar.js @@ -1,5 +1,5 @@ /** - * ## [new] Blaze.ReactiveVar(initialValue, [equalsFunc]) + * ## [new] Blaze._ReactiveVar(initialValue, [equalsFunc]) * * A ReactiveVar holds a single value that can be get and set, * such that calling `set` will invalidate any Computations that @@ -26,17 +26,17 @@ * it into the ReactiveVar of Geoff's Lickable Forms proposal. */ -Blaze.ReactiveVar = function (initialValue, equalsFunc) { - if (! (this instanceof Blaze.ReactiveVar)) +Blaze._ReactiveVar = function (initialValue, equalsFunc) { + if (! (this instanceof Blaze._ReactiveVar)) // called without `new` - return new Blaze.ReactiveVar(initialValue, equalsFunc); + return new Blaze._ReactiveVar(initialValue, equalsFunc); this.curValue = initialValue; this.equalsFunc = equalsFunc; this.dep = new Deps.Dependency; }; -Blaze.ReactiveVar._isEqual = function (oldValue, newValue) { +Blaze._ReactiveVar._isEqual = function (oldValue, newValue) { var a = oldValue, b = newValue; // Two values are "equal" here if they are `===` and are // number, boolean, string, undefined, or null. @@ -47,17 +47,17 @@ Blaze.ReactiveVar._isEqual = function (oldValue, newValue) { (typeof a === 'string')); }; -Blaze.ReactiveVar.prototype.get = function () { +Blaze._ReactiveVar.prototype.get = function () { if (Deps.active) this.dep.depend(); return this.curValue; }; -Blaze.ReactiveVar.prototype.set = function (newValue) { +Blaze._ReactiveVar.prototype.set = function (newValue) { var oldValue = this.curValue; - if ((this.equalsFunc || Blaze.ReactiveVar._isEqual)(oldValue, newValue)) + if ((this.equalsFunc || Blaze._ReactiveVar._isEqual)(oldValue, newValue)) // value is same as last time return; @@ -65,6 +65,6 @@ Blaze.ReactiveVar.prototype.set = function (newValue) { this.dep.changed(); }; -Blaze.ReactiveVar.prototype.toString = function () { +Blaze._ReactiveVar.prototype.toString = function () { return 'ReactiveVar{' + this.get() + '}'; }; diff --git a/packages/blaze/view.js b/packages/blaze/view.js index fa44971342..0bd0b4c994 100644 --- a/packages/blaze/view.js +++ b/packages/blaze/view.js @@ -201,7 +201,7 @@ Blaze._materializeView = function (view, parentView) { view.isInRender = false; Deps.nonreactive(function doMaterialize() { - var materializer = new Blaze.DOMMaterializer({parentView: view}); + var materializer = new Blaze._DOMMaterializer({parentView: view}); var rangesAndNodes = materializer.visit(htmljs, []); if (c.firstRun || ! Blaze._isContentEqual(lastHtmljs, htmljs)) { if (c.firstRun) { @@ -281,8 +281,8 @@ Blaze._expandView = function (view, parentView) { }; // Options: `parentView` -Blaze.HTMLJSExpander = HTML.TransformingVisitor.extend(); -Blaze.HTMLJSExpander.def({ +Blaze._HTMLJSExpander = HTML.TransformingVisitor.extend(); +Blaze._HTMLJSExpander.def({ visitObject: function (x) { if (x instanceof Blaze.Template) x = x.constructView(); @@ -320,13 +320,13 @@ var currentViewIfRendering = function () { Blaze._expand = function (htmljs, parentView) { parentView = parentView || currentViewIfRendering(); - return (new Blaze.HTMLJSExpander( + return (new Blaze._HTMLJSExpander( {parentView: parentView})).visit(htmljs); }; Blaze._expandAttributes = function (attrs, parentView) { parentView = parentView || currentViewIfRendering(); - return (new Blaze.HTMLJSExpander( + return (new Blaze._HTMLJSExpander( {parentView: parentView})).visitAttributes(attrs); }; @@ -589,7 +589,7 @@ Blaze._addEventMap = function (view, eventMap, thisInHandler) { var newEvents = parts.shift(); var selector = parts.join(' '); - handles.push(Blaze.EventSupport.listen( + handles.push(Blaze._EventSupport.listen( element, newEvents, selector, function (evt) { if (! range.containsElement(evt.currentTarget)) diff --git a/packages/spacebars-compiler/codegen.js b/packages/spacebars-compiler/codegen.js index 26b6666637..f16cc1e198 100644 --- a/packages/spacebars-compiler/codegen.js +++ b/packages/spacebars-compiler/codegen.js @@ -139,7 +139,7 @@ _.extend(CodeGen.prototype, { if (path[0] === 'UI' && (path[1] === 'contentBlock' || path[1] === 'elseBlock')) { - includeCode = 'Blaze.InOuterTemplateScope(view, function () { return ' + includeCode = 'Blaze._InOuterTemplateScope(view, function () { return ' + includeCode + '; })'; } diff --git a/packages/spacebars/spacebars-runtime.js b/packages/spacebars/spacebars-runtime.js index 5114f061eb..b6d617b4d5 100644 --- a/packages/spacebars/spacebars-runtime.js +++ b/packages/spacebars/spacebars-runtime.js @@ -13,7 +13,7 @@ Spacebars.include = function (templateOrFunction, contentFunc, elseFunc) { return templateOrFunction.constructView(contentFunc, elseFunc); } - var templateVar = Blaze.ReactiveVar(null, tripleEquals); + var templateVar = Blaze._ReactiveVar(null, tripleEquals); var view = Blaze.View('Spacebars.include', function () { var template = templateVar.get(); if (template === null) @@ -210,7 +210,7 @@ Spacebars.dot = function (value, id1/*, id2, ...*/) { // case, since the else block is evaluated without entering // a new data context). Spacebars.With = function (argFunc, contentFunc, elseFunc) { - var argVar = new Blaze.ReactiveVar; + var argVar = new Blaze._ReactiveVar; var view = Blaze.View('Spacebars_with', function () { return Blaze.If(function () { return argVar.get(); }, function () { return Blaze.With(function () {