mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Fix #4097: error when View invalidated immediately
Bug introduced in 28c760e
This commit is contained in:
committed by
Slava Kim
parent
4689ee7dfa
commit
8b2c642df1
@@ -354,7 +354,9 @@ Blaze._materializeView = function (view, parentView, _workStack, _intoArray) {
|
||||
// helpers in the DOM tree to be replaced might be scheduled
|
||||
// to re-run before we have a chance to stop them.
|
||||
Tracker.onInvalidate(function () {
|
||||
domrange.destroyMembers();
|
||||
if (domrange) {
|
||||
domrange.destroyMembers();
|
||||
}
|
||||
});
|
||||
}, undefined, 'materialize');
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
{{/if}}
|
||||
</template>
|
||||
|
||||
<template name="spacebars_template_test_bracketed_foo">
|
||||
[{{foo}}]
|
||||
</template>
|
||||
|
||||
<!-- -->
|
||||
|
||||
|
||||
|
||||
@@ -2749,6 +2749,30 @@ Tinytest.add('spacebars-tests - template_tests - current view in event handler',
|
||||
});
|
||||
|
||||
|
||||
Tinytest.add('spacebars-tests - template_tests - helper invalidates self', function (test) {
|
||||
var tmpl = Template.spacebars_template_test_bracketed_foo;
|
||||
|
||||
var count = new ReactiveVar(0);
|
||||
|
||||
tmpl.helpers({
|
||||
// It's unusual for a helper to have side effects, but it's possible
|
||||
// and people do it. Regression test for #4097.
|
||||
foo: function () {
|
||||
// Make count odd and return it.
|
||||
var c = count.get();
|
||||
if ((c % 2) === 0) {
|
||||
count.set(c+1);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
});
|
||||
|
||||
var div = renderToDiv(tmpl);
|
||||
divRendersTo(test, div, '[1]');
|
||||
count.set(2);
|
||||
divRendersTo(test, div, '[3]');
|
||||
});
|
||||
|
||||
Tinytest.add(
|
||||
"spacebars-tests - template_tests - textarea attrs", function (test) {
|
||||
var tmplNoContents = {
|
||||
|
||||
Reference in New Issue
Block a user