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

Commit

Permalink
add OPTGROUP as an attribute template
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelw committed May 22, 2013
1 parent 033257a commit af1733d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@
'COLGROUP': true,
'COL': true,
'CAPTION': true,
'OPTION': true
'OPTION': true,
'OPTGROUP': true
};

var hasTemplateElement = typeof HTMLTemplateElement !== 'undefined';
Expand Down
32 changes: 21 additions & 11 deletions tests/template_element.js
Original file line number Diff line number Diff line change
Expand Up @@ -1065,28 +1065,38 @@ suite('Template Element', function() {
assert.strictEqual('Item 2', div.childNodes[i++].textContent);
});

test('Attribute Template Option', function() {
test('Attribute Template Optgroup/Option', function() {
var div = createTestHtml(
'<template bind>' +
'<select>' +
'<option template repeat>{{ val }}</option>' +
'<select">' +
'<optgroup template repeat="{{ groups }}" label="{{ name }}">' +
'<option template repeat="{{ items }}">{{ val }}</option>' +
'</optgroup>' +
'</select>' +
'</template>');

var m = [{ val: 0 }, { val: 1 }];
var m = {
selected: 1,
groups: [
{
name: "one", items: [{ val: 0 }, { val: 1 }]
}
],
};

recursivelySetTemplateModel(div, m);
Platform.performMicrotaskCheckpoint();

var select = div.firstChild.nextSibling;
assert.strictEqual(3, select.childNodes.length);
assert.strictEqual(2, select.childNodes.length);
assert.strictEqual('TEMPLATE', select.childNodes[0].tagName);
assert.strictEqual('OPTION',
select.childNodes[0].ref.content.firstChild.tagName);
assert.strictEqual('OPTION', select.childNodes[1].tagName);
assert.strictEqual('0', select.childNodes[1].textContent);
assert.strictEqual('OPTION', select.childNodes[2].tagName);
assert.strictEqual('1', select.childNodes[2].textContent);
assert.strictEqual('OPTGROUP', select.childNodes[0].ref.content.firstChild.tagName);
var optgroup = select.childNodes[1];
assert.strictEqual('TEMPLATE', optgroup.childNodes[0].tagName);
assert.strictEqual('OPTION', optgroup.childNodes[1].tagName);
assert.strictEqual('0', optgroup.childNodes[1].textContent);
assert.strictEqual('OPTION', optgroup.childNodes[2].tagName);
assert.strictEqual('1', optgroup.childNodes[2].textContent);
});

test('NestedIterateTableMixedSemanticNative', function() {
Expand Down

0 comments on commit af1733d

Please sign in to comment.