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

Commit

Permalink
Merge pull request #129 from jmesserly/empty-if
Browse files Browse the repository at this point in the history
Add support for empty if, similar to bind and repeat.
  • Loading branch information
rafaelw committed Aug 1, 2013
2 parents edd23f6 + f8f58e1 commit 75e63f5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@
if (isTemplateNode) {
if (name === IF) {
ifFound = true;
value = value || '{{}}'; // Accept 'naked' if.
} else if (name === BIND || name === REPEAT) {
bindFound = true;
value = value || '{{}}'; // Accept 'naked' bind & repeat.
Expand Down
14 changes: 14 additions & 0 deletions tests/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ suite('Template Element', function() {
assert.strictEqual('foo', div.lastChild.textContent);
});

test('Template-Empty If', function() {
var div = createTestHtml(
'<template if>{{ value }}</template>');
var m = { value: 'foo' };
recursivelySetTemplateModel(div, null);
Platform.performMicrotaskCheckpoint();
assert.strictEqual(1, div.childNodes.length);

recursivelySetTemplateModel(div, m);
Platform.performMicrotaskCheckpoint();
assert.strictEqual(2, div.childNodes.length);
assert.strictEqual('foo', div.lastChild.textContent);
});

test('Template Repeat If', function() {
var div = createTestHtml(
'<template repeat="{{ foo }}" if="{{ bar }}">{{ }}</template>');
Expand Down

0 comments on commit 75e63f5

Please sign in to comment.