diff --git a/src/TemplateBinding.js b/src/TemplateBinding.js index 5e6bd38..8db0e8a 100644 --- a/src/TemplateBinding.js +++ b/src/TemplateBinding.js @@ -496,7 +496,8 @@ ref = treeScope.getElementById(refId); if (!ref) { var instanceRoot = getInstanceRoot(this); - ref = instanceRoot.querySelector('#' + refId); + if (instanceRoot) + ref = instanceRoot.querySelector('#' + refId); } } diff --git a/tests/tests.js b/tests/tests.js index c45a8a0..6354a76 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -3006,6 +3006,17 @@ suite('Binding Delegate API', function() { done(); }); }); + + test('issue-152', function() { + var div = createTestHtml( + ''); + + var template = div.firstChild; + + // if a ref cannot be located, a template will continue to use itself + // as the source of template instances. + assert.strictEqual(template, template.ref); + }); }); suite('Compat', function() {