@@ -282,21 +282,20 @@ angular.module('ui.select', [])
282
282
$document . off ( 'mousedown' ) ;
283
283
} ) ;
284
284
285
- // Move transcluded elements to their correct position on main template
285
+ // Move transcluded elements to their correct position in main template
286
286
transcludeFn ( scope , function ( clone ) {
287
- var transcluded = angular . element ( '<div>' ) . append ( clone ) ;
287
+ // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
288
288
289
- // Child directives could be uncompiled at this point, so we check both alternatives,
290
- // first for compiled version (by class) or uncompiled (by tag). We place the directives
291
- // at the insertion points that are marked with ui-select-* classes inside the templates
289
+ // One day jqLite will be replaced by jQuery and we will be able to write:
290
+ // var transcludedElement = clone.filter('.my-class')
291
+ // instead of creating a hackish DOM element:
292
+ var transcluded = angular . element ( '<div>' ) . append ( clone ) ;
292
293
293
- var transMatch = transcluded . querySelectorAll ( '.ui-select-match' ) ;
294
- transMatch = ! transMatch . length ? transcluded . find ( 'match' ) : transMatch ;
295
- element . querySelectorAll ( '.ui-select-match' ) . replaceWith ( transMatch ) ;
294
+ var transcludedMatch = transcluded . querySelectorAll ( '.ui-select-match' ) ;
295
+ element . querySelectorAll ( '.ui-select-match' ) . replaceWith ( transcludedMatch ) ;
296
296
297
- var transChoices = transcluded . querySelectorAll ( '.ui-select-choices' ) ;
298
- transChoices = ! transChoices . length ? transcluded . find ( 'choices' ) : transChoices ;
299
- element . querySelectorAll ( '.ui-select-choices' ) . replaceWith ( transChoices ) ;
297
+ var transcludedChoices = transcluded . querySelectorAll ( '.ui-select-choices' ) ;
298
+ element . querySelectorAll ( '.ui-select-choices' ) . replaceWith ( transcludedChoices ) ;
300
299
} ) ;
301
300
}
302
301
} ;
0 commit comments