mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Merge branch 'revert-current-data' into devel
This commit is contained in:
@@ -490,10 +490,10 @@ Template.instance = function () {
|
||||
*
|
||||
* - Inside an `onCreated`, `onRendered`, or `onDestroyed` callback, returns
|
||||
* the data context of the template.
|
||||
* - Inside an event handler, returns the data context of the template on which
|
||||
* this event handler was defined.
|
||||
* - Inside a helper, returns the data context of the DOM node where the helper
|
||||
* was used.
|
||||
* - Inside an event handler, returns the data context of the element that fired
|
||||
* the event.
|
||||
*
|
||||
* Establishes a reactive dependency on the result.
|
||||
* @locus Client
|
||||
|
||||
@@ -817,10 +817,9 @@ Blaze._addEventMap = function (view, eventMap, thisInHandler) {
|
||||
return null;
|
||||
var handlerThis = thisInHandler || this;
|
||||
var handlerArgs = arguments;
|
||||
return Blaze._withCurrentView(Blaze.getView(evt.currentTarget),
|
||||
function () {
|
||||
return handler.apply(handlerThis, handlerArgs);
|
||||
});
|
||||
return Blaze._withCurrentView(view, function () {
|
||||
return handler.apply(handlerThis, handlerArgs);
|
||||
});
|
||||
},
|
||||
range, function (r) {
|
||||
return r.parentRange;
|
||||
|
||||
@@ -1028,14 +1028,6 @@ Hi there!
|
||||
{{> Template.contentBlock}}
|
||||
</template>
|
||||
|
||||
<template name="spacebars_template_test_currentData_and_parentData_in_events">
|
||||
{{#with x=1}}
|
||||
{{#with y=2}}
|
||||
<button>{{label}}</button>
|
||||
{{/with}}
|
||||
{{/with}}
|
||||
</template>
|
||||
|
||||
<template name="spacebars_template_test_template_level_subscriptions">
|
||||
{{#if Template.subscriptionsReady}}
|
||||
ready!
|
||||
|
||||
@@ -19,7 +19,6 @@ var inDocument = function (elem) {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
var clickIt = function (elem) {
|
||||
if (!inDocument(elem))
|
||||
throw new Error("Can't click on elements without first adding them to the document");
|
||||
@@ -3098,45 +3097,6 @@ Tinytest.add("spacebars-tests - template_tests - custom block helper doesn't bre
|
||||
test.equal(canonicalizeHtml(div.innerHTML), "hello hello");
|
||||
});
|
||||
|
||||
Tinytest.add(
|
||||
"spacebars-tests - template_tests - currentData and parentData in event handlers and helpers",
|
||||
function (test) {
|
||||
var tmpl = Template.spacebars_template_test_currentData_and_parentData_in_events;
|
||||
|
||||
var clicked = false;
|
||||
var currentInEvent;
|
||||
var parentInEvent;
|
||||
var currentInHelper;
|
||||
var parentInHelper;
|
||||
|
||||
tmpl.events({
|
||||
'click button': function () {
|
||||
currentInEvent = Template.currentData();
|
||||
parentInEvent = Template.parentData(1);
|
||||
}
|
||||
});
|
||||
|
||||
tmpl.helpers({
|
||||
label: function () {
|
||||
currentInHelper = Template.currentData();
|
||||
parentInHelper = Template.parentData(1);
|
||||
}
|
||||
});
|
||||
|
||||
var div = renderToDiv(tmpl);
|
||||
var button = div.querySelector('button');
|
||||
document.body.appendChild(div);
|
||||
|
||||
clickIt(button);
|
||||
|
||||
test.equal(currentInEvent, {y: 2});
|
||||
test.equal(parentInEvent, {x: 1});
|
||||
test.equal(currentInHelper, {y: 2});
|
||||
test.equal(parentInHelper, {x: 1});
|
||||
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
testAsyncMulti("spacebars-tests - template_tests - template-level subscriptions", [
|
||||
function (test, expect) {
|
||||
var tmpl = Template.spacebars_template_test_template_level_subscriptions;
|
||||
|
||||
Reference in New Issue
Block a user