mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-19 03:51:07 +00:00
compile but don't bind option elements nested in a nameless select
otherwise an exception is thrown unexpectidly
This commit is contained in:
parent
9368ea3814
commit
9e0fa5b7c8
2 changed files with 18 additions and 0 deletions
|
|
@ -545,6 +545,10 @@ angularWidget('option', function(){
|
||||||
var isMultiple = select[0].type == 'select-multiple';
|
var isMultiple = select[0].type == 'select-multiple';
|
||||||
var scope = retrieveScope(select);
|
var scope = retrieveScope(select);
|
||||||
var model = modelAccessor(scope, 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 formattedModel = modelFormattedAccessor(scope, select);
|
||||||
var view = isMultiple
|
var view = isMultiple
|
||||||
? optionsAccessor(scope, select)
|
? optionsAccessor(scope, select)
|
||||||
|
|
|
||||||
|
|
@ -463,6 +463,20 @@ describe("widget", function(){
|
||||||
expect(scope.selection).toBe(scope.objs[0]);
|
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(){
|
describe('select-multiple', function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue