compile but don't bind option elements nested in a nameless select

otherwise an exception is thrown unexpectidly
This commit is contained in:
Igor Minar 2011-01-25 17:51:01 -08:00
parent 9368ea3814
commit 9e0fa5b7c8
2 changed files with 18 additions and 0 deletions

View file

@ -545,6 +545,10 @@ angularWidget('option', function(){
var isMultiple = select[0].type == 'select-multiple';
var scope = retrieveScope(select);
var model = modelAccessor(scope, select);
//if parent select doesn't have a name, don't bother doing anything any more
if (!model) return;
var formattedModel = modelFormattedAccessor(scope, select);
var view = isMultiple
? optionsAccessor(scope, select)

View file

@ -463,6 +463,20 @@ describe("widget", function(){
expect(scope.selection).toBe(scope.objs[0]);
});
it('should compile children of a select without a name, but not create a model for it',
function() {
compile('<select>' +
'<option selected="true">{{a}}</option>' +
'<option value="">{{b}}</option>' +
'<option>C</option>' +
'</select>');
scope.a = 'foo';
scope.b = 'bar';
scope.$eval();
expect(scope.$element.text()).toBe('foobarC');
})
});
describe('select-multiple', function(){