@@ -429,6 +429,9 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
429
429
}
430
430
}
431
431
432
+ // The empty option will be compiled and rendered before we first generate the options
433
+ selectElement . empty ( ) ;
434
+
432
435
var providedEmptyOption = ! ! selectCtrl . emptyOption ;
433
436
434
437
var unknownOption = jqLite ( optionTemplate . cloneNode ( false ) ) ;
@@ -545,13 +548,11 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
545
548
546
549
if ( providedEmptyOption ) {
547
550
548
- // we need to remove it before calling selectElement.empty() because otherwise IE will
549
- // remove the label from the element. wtf?
550
- selectCtrl . emptyOption . remove ( ) ;
551
-
552
551
// compile the element since there might be bindings in it
553
552
$compile ( selectCtrl . emptyOption ) ( scope ) ;
554
553
554
+ selectElement . prepend ( selectCtrl . emptyOption ) ;
555
+
555
556
if ( selectCtrl . emptyOption [ 0 ] . nodeType === NODE_TYPE_COMMENT ) {
556
557
// This means the empty option has currently no actual DOM node, probably because
557
558
// it has been modified by a transclusion directive.
@@ -583,8 +584,6 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
583
584
584
585
}
585
586
586
- selectElement . empty ( ) ;
587
-
588
587
// We need to do this here to ensure that the options object is defined
589
588
// when we first hit it in writeNgOptionsValue
590
589
updateOptions ( ) ;
@@ -649,16 +648,6 @@ var ngOptionsDirective = ['$compile', '$document', '$parse', function($compile,
649
648
650
649
var groupElementMap = { } ;
651
650
652
- // Ensure that the empty option is always there if it was explicitly provided
653
- if ( providedEmptyOption ) {
654
-
655
- if ( selectCtrl . unknownOption . parent ( ) . length ) {
656
- selectCtrl . unknownOption . after ( selectCtrl . emptyOption ) ;
657
- } else {
658
- selectElement . prepend ( selectCtrl . emptyOption ) ;
659
- }
660
- }
661
-
662
651
options . items . forEach ( function addOption ( option ) {
663
652
var groupElement ;
664
653
0 commit comments