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

Commit 3111501

Browse files
bekospkozlowski-opensource
authored andcommitted
refactor(typeahead): use ng-if and track by in template
Closes #1722
1 parent 09678b1 commit 3111501

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/typeahead/test/typeahead.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('typeahead tests', function () {
7070
this.message = function () {
7171
return 'Expected "' + angular.mock.dump(typeaheadEl) + '" to be closed.';
7272
};
73-
return typeaheadEl.css('display') === 'none' && findMatches(this.actual).length === 0;
73+
return typeaheadEl.length === 0;
7474

7575
}, toBeOpenWithActive: function (noOfMatches, activeIdx) {
7676

@@ -80,7 +80,7 @@ describe('typeahead tests', function () {
8080
this.message = function () {
8181
return 'Expected "' + this.actual + '" to be opened.';
8282
};
83-
return typeaheadEl.css('display') === 'block' && liEls.length === noOfMatches && $(liEls[activeIdx]).hasClass('active');
83+
return typeaheadEl.length === 1 && liEls.length === noOfMatches && $(liEls[activeIdx]).hasClass('active');
8484
}
8585
});
8686
});
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<ul class="dropdown-menu" ng-style="{display: isOpen()&&'block' || 'none', top: position.top+'px', left: position.left+'px'}">
2-
<li ng-repeat="match in matches" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)">
1+
<ul class="dropdown-menu" ng-if="isOpen()" ng-style="{top: position.top+'px', left: position.left+'px'}" style="display: block;">
2+
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)">
33
<div typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
44
</li>
55
</ul>

0 commit comments

Comments
 (0)