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

Commit

Permalink
fix(typeahead): correctly handle append to body attribute
Browse files Browse the repository at this point in the history
Closes #1656
  • Loading branch information
pkozlowski-opensource committed Jan 24, 2014
1 parent c188416 commit 1078573
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/typeahead/test/typeahead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('typeahead tests', function () {
toBeClosed: function () {
var typeaheadEl = findDropDown(this.actual);
this.message = function () {
return 'Expected "' + angular.mock.dump(this.actual) + '" to be closed.';
return 'Expected "' + angular.mock.dump(typeaheadEl) + '" to be closed.';
};
return typeaheadEl.css('display') === 'none' && findMatches(this.actual).length === 0;

Expand Down Expand Up @@ -588,6 +588,12 @@ describe('typeahead tests', function () {
changeInputValueTo(element, 'ba');
expect($document.find('body')).toBeOpenWithActive(2, 0);
});

it('should not append to body when value of the attribute is false', function () {
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source | filter:$viewValue" typeahead-append-to-body="false"></div>');
changeInputValueTo(element, 'ba');
expect(findDropDown($document.find('body')).length).toEqual(0);
});
});

});
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap

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

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

//INTERNAL VARIABLES

Expand Down

0 comments on commit 1078573

Please sign in to comment.