Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix template.ref
Browse files Browse the repository at this point in the history
R=arv, jmesserly
BUG=

Review URL: https://codereview.appspot.com/52350043
  • Loading branch information
rafaelw committed Jan 14, 2014
1 parent b0d1fc9 commit 5c5109f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/TemplateBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@
ref = treeScope.getElementById(refId);
if (!ref) {
var instanceRoot = getInstanceRoot(this);
ref = instanceRoot.querySelector('#' + refId);
if (instanceRoot)
ref = instanceRoot.querySelector('#' + refId);
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3006,6 +3006,17 @@ suite('Binding Delegate API', function() {
done();
});
});

test('issue-152', function() {
var div = createTestHtml(
'<template ref=notThere></template>');

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() {
Expand Down

0 comments on commit 5c5109f

Please sign in to comment.