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

Commit

Permalink
add support for 'if' for attribute templates
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemac53 committed Jan 9, 2015
1 parent 5f0b9b1 commit 8f23197
Show file tree
Hide file tree
Showing 2 changed files with 25 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 @@ -135,7 +135,8 @@
'template': true,
'repeat': true,
'bind': true,
'ref': true
'ref': true,
'if': true
};

var semanticTemplateElements = {
Expand Down
23 changes: 23 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,29 @@ suite('Template Instantiation', function() {
});
});

test('Attribute Template If', function(done) {
var div = createTestHtml(
'<template bind><table><tbody>' +
'<tr template if="{{falseItem}}"><td>Should be invisible</td></tr>' +
'<tr template if="{{trueItem}}"><td>Should be visible</td></tr>' +
'<tbody></table></template>')

var template = div.querySelector('template');
var m = {
falseItem: false,
trueItem: true
};
template.model = m;

then(function() {
var tbody = div.querySelector('tbody');
assert.strictEqual(3, tbody.childNodes.length);
assert.strictEqual('<td>Should be visible</td>',
tbody.childNodes[2].innerHTML);
done();
});
});

test('NestedIterateTableMixedSemanticNative', function(done) {
if (!parserHasNativeTemplate) {
done();
Expand Down

0 comments on commit 8f23197

Please sign in to comment.