@@ -162,6 +162,32 @@ uis.directive('uiSelect',
162
162
$document . off ( 'click' , onDocumentClick ) ;
163
163
} ) ;
164
164
165
+ // Move transcluded elements to their correct position in main template
166
+ transcludeFn ( scope , function ( clone ) {
167
+ // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
168
+
169
+ // One day jqLite will be replaced by jQuery and we will be able to write:
170
+ // var transcludedElement = clone.filter('.my-class')
171
+ // instead of creating a hackish DOM element:
172
+ var transcluded = angular . element ( '<div>' ) . append ( clone ) ;
173
+
174
+ var transcludedMatch = transcluded . querySelectorAll ( '.ui-select-match' ) ;
175
+ transcludedMatch . removeAttr ( 'ui-select-match' ) ; //To avoid loop in case directive as attr
176
+ transcludedMatch . removeAttr ( 'data-ui-select-match' ) ; // Properly handle HTML5 data-attributes
177
+ if ( transcludedMatch . length !== 1 ) {
178
+ throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-match but got '{0}'." , transcludedMatch . length ) ;
179
+ }
180
+ element . querySelectorAll ( '.ui-select-match' ) . replaceWith ( transcludedMatch ) ;
181
+
182
+ var transcludedChoices = transcluded . querySelectorAll ( '.ui-select-choices' ) ;
183
+ transcludedChoices . removeAttr ( 'ui-select-choices' ) ; //To avoid loop in case directive as attr
184
+ transcludedChoices . removeAttr ( 'data-ui-select-choices' ) ; // Properly handle HTML5 data-attributes
185
+ if ( transcludedChoices . length !== 1 ) {
186
+ throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-choices but got '{0}'." , transcludedChoices . length ) ;
187
+ }
188
+ element . querySelectorAll ( '.ui-select-choices' ) . replaceWith ( transcludedChoices ) ;
189
+ } ) ;
190
+
165
191
// Support for appending the select field to the body when its open
166
192
var appendToBody = scope . $eval ( attrs . appendToBody ) ;
167
193
if ( appendToBody !== undefined ? appendToBody : uiSelectConfig . appendToBody ) {
@@ -222,32 +248,6 @@ uis.directive('uiSelect',
222
248
element [ 0 ] . style . top = '' ;
223
249
element [ 0 ] . style . width = originalWidth ;
224
250
}
225
-
226
- // Move transcluded elements to their correct position in main template
227
- transcludeFn ( scope , function ( clone ) {
228
- // See Transclude in AngularJS http://blog.omkarpatil.com/2012/11/transclude-in-angularjs.html
229
-
230
- // One day jqLite will be replaced by jQuery and we will be able to write:
231
- // var transcludedElement = clone.filter('.my-class')
232
- // instead of creating a hackish DOM element:
233
- var transcluded = angular . element ( '<div>' ) . append ( clone ) ;
234
-
235
- var transcludedMatch = transcluded . querySelectorAll ( '.ui-select-match' ) ;
236
- transcludedMatch . removeAttr ( 'ui-select-match' ) ; //To avoid loop in case directive as attr
237
- transcludedMatch . removeAttr ( 'data-ui-select-match' ) ; // Properly handle HTML5 data-attributes
238
- if ( transcludedMatch . length !== 1 ) {
239
- throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-match but got '{0}'." , transcludedMatch . length ) ;
240
- }
241
- element . querySelectorAll ( '.ui-select-match' ) . replaceWith ( transcludedMatch ) ;
242
-
243
- var transcludedChoices = transcluded . querySelectorAll ( '.ui-select-choices' ) ;
244
- transcludedChoices . removeAttr ( 'ui-select-choices' ) ; //To avoid loop in case directive as attr
245
- transcludedChoices . removeAttr ( 'data-ui-select-choices' ) ; // Properly handle HTML5 data-attributes
246
- if ( transcludedChoices . length !== 1 ) {
247
- throw uiSelectMinErr ( 'transcluded' , "Expected 1 .ui-select-choices but got '{0}'." , transcludedChoices . length ) ;
248
- }
249
- element . querySelectorAll ( '.ui-select-choices' ) . replaceWith ( transcludedChoices ) ;
250
- } ) ;
251
251
} ;
252
252
}
253
253
} ;
0 commit comments