@@ -243,11 +243,12 @@ angularWidget('select', function(element){
243
243
244
244
// find existing special options
245
245
forEach ( selectElement . children ( ) , function ( option ) {
246
- var opt ;
247
246
if ( option . value == '' ) {
248
- opt = jqLite ( option ) ;
249
247
// User is allowed to select the null.
250
- nullOption = { label :opt . text ( ) , id :'' , bindTemplate : opt . attr ( 'ng:bind-template' ) } ;
248
+ // save <option> element
249
+ nullOption = jqLite ( option ) . remove ( ) ;
250
+ // compile it in model scope
251
+ compile ( nullOption ) ( modelScope ) ;
251
252
}
252
253
} ) ;
253
254
selectElement . html ( '' ) ; // clear contents
@@ -318,7 +319,7 @@ angularWidget('select', function(element){
318
319
selectedSet = new HashMap ( modelValue ) ;
319
320
} else if ( modelValue === null || nullOption ) {
320
321
// if we are not multiselect, and we are null then we have to add the nullOption
321
- optionGroups [ '' ] . push ( extend ( { selected :modelValue === null , id :'' , label :'' } , nullOption ) ) ;
322
+ optionGroups [ '' ] . push ( { selected :modelValue === null , id :'' , label :'' } ) ;
322
323
selectedSet = true ;
323
324
}
324
325
@@ -393,19 +394,19 @@ angularWidget('select', function(element){
393
394
}
394
395
} else {
395
396
// grow elements
396
- // jQuery(v1.4.2) Bug: We should be able to chain the method calls, but
397
- // in this version of jQuery on some browser the .text() returns a string
398
- // rather then the element.
399
- ( element = optionTemplate . clone ( ) )
400
- . val ( option . id )
401
- . attr ( 'selected' , option . selected )
402
- . text ( option . label ) ;
403
-
404
- // if it's a nullOption, compile it
405
- if ( option . id === '' ) {
406
- if ( option . bindTemplate )
407
- element . attr ( 'ng:bind-template ' , option . bindTemplate ) ;
408
- compile ( element ) ( modelScope ) ;
397
+
398
+ // if it's a null option
399
+ if ( option . id === '' && nullOption ) {
400
+ // put back the pre-compiled element
401
+ element = nullOption ;
402
+ } else {
403
+ // jQuery(v1.4.2) Bug: We should be able to chain the method calls, but
404
+ // in this version of jQuery on some browser the .text() returns a string
405
+ // rather then the element.
406
+ ( element = optionTemplate . clone ( ) )
407
+ . val ( option . id )
408
+ . attr ( 'selected ' , option . selected )
409
+ . text ( option . label ) ;
409
410
}
410
411
411
412
existingOptions . push ( existingOption = {
0 commit comments