diff options
author | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-09-26 16:31:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-26 16:31:54 +0300 |
commit | e4993711f96af59187dd2e13ad4e72ac1dbd5b93 (patch) | |
tree | b495e0b74820f273b3a34bc9787b06438dc80223 | |
parent | ed99eae60cfefd09fab38f73ef18b4fbb873253e (diff) | |
parent | ed29356d2e5c8a19d97ef7f4b90cdcb4e9f58768 (diff) | |
download | awesomplete-e4993711f96af59187dd2e13ad4e72ac1dbd5b93.zip awesomplete-e4993711f96af59187dd2e13ad4e72ac1dbd5b93.tar.gz awesomplete-e4993711f96af59187dd2e13ad4e72ac1dbd5b93.tar.bz2 |
Don't match if trimmed input is empty string (fix for #16934)
-rw-r--r-- | awesomplete.js | 2 | ||||
-rw-r--r-- | test/static/itemSpec.js | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/awesomplete.js b/awesomplete.js index 367636e..4a0e7e8 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -284,7 +284,7 @@ _.SORT_BYLENGTH = function (a, b) { }; _.ITEM = function (text, input) { - var html = input === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>"); + var html = input.trim() === '' ? text : text.replace(RegExp($.regExpEscape(input.trim()), "gi"), "<mark>$&</mark>"); return $.create("li", { innerHTML: html, "aria-selected": "false" diff --git a/test/static/itemSpec.js b/test/static/itemSpec.js index 95ae2a8..ee89193 100644 --- a/test/static/itemSpec.js +++ b/test/static/itemSpec.js @@ -47,4 +47,12 @@ describe("Awesomplete.ITEM", function () { expect(this.element.innerHTML).toBe("JavaScript"); }); }); + + describe("with space input", function () { + def("input", " "); + + it("does not mark anything", function () { + expect(this.element.innerHTML).toBe("JavaScript"); + }); + }); }); |