mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Make more Blaze calls private
Put underscores before: ReactiveVar, InOuterTemplateScope, EventSupport, reportException, wrapCatchingExceptions, DOMMaterializer, and HTMLJSExpander
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var EventSupport = Blaze.EventSupport = {};
|
||||
var EventSupport = Blaze._EventSupport = {};
|
||||
|
||||
var DOMBackend = Blaze._DOMBackend;
|
||||
|
||||
|
||||
@@ -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 + ':');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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 !!!
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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() + '}';
|
||||
};
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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 + '; })';
|
||||
}
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user