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

Commit 1078573

Browse files
fix(typeahead): correctly handle append to body attribute
Closes #1656
1 parent c188416 commit 1078573

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/typeahead/test/typeahead.spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('typeahead tests', function () {
6868
toBeClosed: function () {
6969
var typeaheadEl = findDropDown(this.actual);
7070
this.message = function () {
71-
return 'Expected "' + angular.mock.dump(this.actual) + '" to be closed.';
71+
return 'Expected "' + angular.mock.dump(typeaheadEl) + '" to be closed.';
7272
};
7373
return typeaheadEl.css('display') === 'none' && findMatches(this.actual).length === 0;
7474

@@ -588,6 +588,12 @@ describe('typeahead tests', function () {
588588
changeInputValueTo(element, 'ba');
589589
expect($document.find('body')).toBeOpenWithActive(2, 0);
590590
});
591+
592+
it('should not append to body when value of the attribute is false', function () {
593+
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source | filter:$viewValue" typeahead-append-to-body="false"></div>');
594+
changeInputValueTo(element, 'ba');
595+
expect(findDropDown($document.find('body')).length).toEqual(0);
596+
});
591597
});
592598

593599
});

src/typeahead/typeahead.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
5757

5858
var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
5959

60-
var appendToBody = attrs.typeaheadAppendToBody ? $parse(attrs.typeaheadAppendToBody) : false;
60+
var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
6161

6262
//INTERNAL VARIABLES
6363

0 commit comments

Comments
 (0)