From 2e191e0b09736111b8530643063d9aa1561dee80 Mon Sep 17 00:00:00 2001 From: David Greenspan Date: Wed, 16 Jul 2014 15:06:13 -0700 Subject: [PATCH] Add regression tests for d56d9da MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure inclusions with one path segment like “..” and “foo” (where foo is in the data context) don’t cause the enclosing template to re-render when the data context changes. --- packages/spacebars-tests/template_tests.html | 20 +++++++++++ packages/spacebars-tests/template_tests.js | 36 ++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/packages/spacebars-tests/template_tests.html b/packages/spacebars-tests/template_tests.html index df108a2885..bfd11eef8f 100644 --- a/packages/spacebars-tests/template_tests.html +++ b/packages/spacebars-tests/template_tests.html @@ -902,3 +902,23 @@ Hi there! + + + + + + + + diff --git a/packages/spacebars-tests/template_tests.js b/packages/spacebars-tests/template_tests.js index 9274471281..be5ec6d068 100644 --- a/packages/spacebars-tests/template_tests.js +++ b/packages/spacebars-tests/template_tests.js @@ -2572,3 +2572,39 @@ Tinytest.add( document.body.removeChild(div); }); + +_.each([1, 2, 3], function (n) { + Tinytest.add( + "spacebars-tests - template_tests - lookup is isolated " + n, + function (test) { + var buf = ""; + var inclusion = Template.spacebars_test_isolated_lookup_inclusion; + inclusion.created = function () { buf += 'C'; }; + inclusion.destroyed = function () { buf += 'D'; }; + + var tmpl = Template['spacebars_test_isolated_lookup' + n]; + var R = ReactiveVar(Template.spacebars_template_test_aaa); + + tmpl.bar = function () { + return R.get(); + }; + + var div = renderToDiv( + tmpl, + function () { + return { foo: R.get() }; + }); + + test.equal(canonicalizeHtml(div.innerHTML), 'aaa--x'); + test.equal(buf, 'C'); + R.set(Template.spacebars_template_test_bbb); + Deps.flush(); + test.equal(canonicalizeHtml(div.innerHTML), 'bbb--x'); + test.equal(buf, 'C'); + R.set(null); + Deps.flush({_throwFirstError:true}); + test.equal(canonicalizeHtml(div.innerHTML), '--x'); + test.equal(buf, 'C'); + } + ); +});