diff options
-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"); + }); + }); }); |