mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Test that #each stops its cursors when removed
This commit is contained in:
@@ -125,6 +125,8 @@ ObserveSequence = {
|
||||
return {
|
||||
stop: function () {
|
||||
computation.stop();
|
||||
if (activeObserveHandle)
|
||||
activeObserveHandle.stop();
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
@@ -263,3 +263,9 @@
|
||||
{{foo}} {{bar}}
|
||||
{{/with}}
|
||||
</template>
|
||||
|
||||
<template name="spacebars_template_test_each_stops">
|
||||
{{#each items}}
|
||||
x
|
||||
{{/each}}
|
||||
</template>
|
||||
|
||||
@@ -821,3 +821,21 @@ Tinytest.add('spacebars - templates - with someData', function (test) {
|
||||
test.equal(someDataRuns, 1);
|
||||
test.equal(trim(stripComments(div.innerHTML)), 'CCC YO');
|
||||
});
|
||||
|
||||
Tinytest.add('spacebars - template - #each stops when rendered element is removed', function (test) {
|
||||
var tmpl = Template.spacebars_template_test_each_stops;
|
||||
var coll = new Meteor.Collection(null);
|
||||
coll.insert({});
|
||||
tmpl.items = function () { return coll.find(); };
|
||||
|
||||
var div = renderToDiv(tmpl);
|
||||
divRendersTo(test, div, 'x');
|
||||
|
||||
// trigger #each component destroyed
|
||||
$(div).remove();
|
||||
|
||||
// insert another document. cursor should no longer be observed so
|
||||
// should have no effect.
|
||||
coll.insert({});
|
||||
divRendersTo(test, div, 'x');
|
||||
});
|
||||
Reference in New Issue
Block a user