aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2011-01-25 17:51:01 -0800
committerIgor Minar2011-01-25 20:49:25 -0800
commit9e0fa5b7c829fcc58a21ab9c3f0cf6492cf793af (patch)
tree8dd2090d00c25500df2655fc346f8c9715717857
parent9368ea38141b8fda1524fdc34c38ecee16ee2afe (diff)
downloadangular.js-9e0fa5b7c829fcc58a21ab9c3f0cf6492cf793af.tar.bz2
compile but don't bind option elements nested in a nameless select
otherwise an exception is thrown unexpectidly
-rw-r--r--src/widgets.js4
-rw-r--r--test/widgetsSpec.js14
2 files changed, 18 insertions, 0 deletions
diff --git a/src/widgets.js b/src/widgets.js
index f90b29a9..cf65cd40 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -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)
diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js
index 0eabc738..2812614f 100644
--- a/test/widgetsSpec.js
+++ b/test/widgetsSpec.js
@@ -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(){