From c7db0df400c1b470a38a1be7648f2347bff89f93 Mon Sep 17 00:00:00 2001 From: Domenico Matteo Date: Tue, 28 Jan 2014 16:16:30 +0100 Subject: [PATCH] fix(typeahead): allow multiple line expression introduce [\s\S]+ to include both whitespace and non whitespace characters Fixes #1687 Closes #1850 --- src/typeahead/test/typeahead.spec.js | 10 ++++++++++ src/typeahead/typeahead.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 6efd0f465c..efd02f552d 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -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('
'); + 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('
'); changeInputValueTo(element, 'b'); diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 832d88e71f..f8babc7c56 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -7,7 +7,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap .factory('typeaheadParser', ['$parse', function ($parse) { // 00000111000000000000022200000000000000003333333333333330000000000044000 - 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) {