mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix some tests (and a comment)
This commit is contained in:
@@ -205,12 +205,10 @@ Tinytest.add("spacebars-tests - template_tests - inclusion args 2", function (te
|
||||
|
||||
// maybe use created callback on the template instead of this?
|
||||
var extendTemplateWithInit = function (template, initFunc) {
|
||||
return template.constructor.extend({
|
||||
constructor: function () {
|
||||
template.constructor.apply(this, arguments);
|
||||
initFunc.call(this);
|
||||
}
|
||||
}).prototype;
|
||||
return Template.__create__(
|
||||
template.__viewName+'-extended',
|
||||
template.__render,
|
||||
initFunc);
|
||||
};
|
||||
|
||||
Tinytest.add("spacebars-tests - template_tests - inclusion dotted args", function (test) {
|
||||
|
||||
@@ -18,7 +18,7 @@ Template.prototype.helpers = function (dict) {
|
||||
|
||||
Template.prototype.events = function (eventMap) {
|
||||
var template = this;
|
||||
template._eventMaps = (template._eventMaps || []);
|
||||
template.__eventMaps = (template.__eventMaps || []);
|
||||
var eventMap2 = {};
|
||||
for (var k in eventMap) {
|
||||
eventMap2[k] = (function (k, v) {
|
||||
@@ -35,7 +35,7 @@ Template.prototype.events = function (eventMap) {
|
||||
})(k, eventMap[k]);
|
||||
}
|
||||
|
||||
template._eventMaps.push(eventMap2);
|
||||
template.__eventMaps.push(eventMap2);
|
||||
};
|
||||
|
||||
Template.prototype.__makeView = function (contentFunc, elseFunc) {
|
||||
@@ -48,27 +48,30 @@ Template.prototype.__makeView = function (contentFunc, elseFunc) {
|
||||
view.templateElseBlock = (
|
||||
elseFunc ? Template.__create__('(elseBlock)', elseFunc) : null);
|
||||
|
||||
if (template._eventMaps ||
|
||||
if (template.__eventMaps ||
|
||||
typeof template.events === 'object') {
|
||||
view.onMaterialized(function () {
|
||||
if (! template._eventMaps &&
|
||||
if (! template.__eventMaps &&
|
||||
typeof template.events === "object") {
|
||||
// Provide limited back-compat support for `.events = {...}`
|
||||
// syntax. Pass `self.events` to the original `.events(...)`
|
||||
// function. This code must run only once per component, in
|
||||
// syntax. Pass `template.events` to the original `.events(...)`
|
||||
// function. This code must run only once per template, in
|
||||
// order to not bind the handlers more than once, which is
|
||||
// ensured by the fact that we only do this when `self._eventMaps`
|
||||
// ensured by the fact that we only do this when `__eventMaps`
|
||||
// is falsy, and we cause it to be set now.
|
||||
Template.prototype.events.call(template, template.events);
|
||||
}
|
||||
|
||||
var range = view.domrange;
|
||||
_.each(template._eventMaps, function (m) {
|
||||
_.each(template.__eventMaps, function (m) {
|
||||
range.addDOMAugmenter(new Blaze.EventAugmenter(m, view));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (template.__initView)
|
||||
template.__initView(view);
|
||||
|
||||
return view;
|
||||
};
|
||||
|
||||
@@ -83,10 +86,13 @@ Template.__lookup__ = function (templateName) {
|
||||
return null;
|
||||
};
|
||||
|
||||
Template.__create__ = function (viewName, templateFunc) {
|
||||
Template.__create__ = function (viewName, templateFunc, initView) {
|
||||
var tmpl = new Template.prototype.constructor;
|
||||
tmpl.__viewName = viewName;
|
||||
tmpl.__render = templateFunc;
|
||||
if (initView)
|
||||
tmpl.__initView = initView;
|
||||
|
||||
return tmpl;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user