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