Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 2eb0de3

Browse files
committed
Simplify transcludeFn
1 parent 2ce0d35 commit 2eb0de3

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/select.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,20 @@ angular.module('ui.select', [])
282282
$document.off('mousedown');
283283
});
284284

285-
// Move transcluded elements to their correct position on main template
285+
// Move transcluded elements to their correct position in main template
286286
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
288288

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);
292293

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);
296296

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);
300299
});
301300
}
302301
};

0 commit comments

Comments
 (0)