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

Add support for empty if, similar to bind and repeat. #129

Merged
merged 1 commit into from
Aug 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,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