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

Commit

Permalink
fix(typeahead): allow multiple line expression
Browse files Browse the repository at this point in the history
introduce [\s\S]+ to include both whitespace and non whitespace
characters

Fixes #1687
Closes #1850
  • Loading branch information
dmatteo authored and pkozlowski-opensource committed May 6, 2014
1 parent aa188ae commit c7db0df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/typeahead/test/typeahead.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,16 @@ describe('typeahead tests', function () {
expect(inputEl.attr('aria-activedescendant')).toBeUndefined();
});

it('should allow expressions over multiple lines', function () {
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source \n' +
'| filter:$viewValue"></div>');
changeInputValueTo(element, 'ba');
expect(element).toBeOpenWithActive(2, 0);

changeInputValueTo(element, '');
expect(element).toBeClosed();
});

it('should not open typeahead if input value smaller than a defined threshold', function () {
var element = prepareInputEl('<div><input ng-model="result" typeahead="item for item in source | filter:$viewValue" typeahead-min-length="2"></div>');
changeInputValueTo(element, 'b');
Expand Down
2 changes: 1 addition & 1 deletion src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap
.factory('typeaheadParser', ['$parse', function ($parse) {

// 00000111000000000000022200000000000000003333333333333330000000000044000

This comment has been minimized.

Copy link
@mamapitufo

mamapitufo Aug 13, 2014

probably this comment should be deleted or updated, as it makes no sense now.

var TYPEAHEAD_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+(.*)$/;
var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;

return {
parse:function (input) {
Expand Down

0 comments on commit c7db0df

Please sign in to comment.