diff options
author | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-01-23 21:07:35 +0300 |
---|---|---|
committer | Vladislav Zarakovsky <vlad.zar@gmail.com> | 2016-01-23 21:07:35 +0300 |
commit | 5abf4df5bda90e2b860955e317820145b4d5ffb2 (patch) | |
tree | edb42cc8a9569edd42ed7abe5b34189fb08b4590 | |
parent | 8bbb86d4fe8cb1b7e51da115dd521ba93d464d3f (diff) | |
download | awesomplete-5abf4df5bda90e2b860955e317820145b4d5ffb2.zip awesomplete-5abf4df5bda90e2b860955e317820145b4d5ffb2.tar.gz awesomplete-5abf4df5bda90e2b860955e317820145b4d5ffb2.tar.bz2 |
Pass origin element to awesomplete-select instead of event
-rw-r--r-- | awesomplete.js | 6 | ||||
-rw-r--r-- | test/events/mousedownSpec.js | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/awesomplete.js b/awesomplete.js index a0eda9c..6a40cc5 100644 --- a/awesomplete.js +++ b/awesomplete.js @@ -97,7 +97,7 @@ var _ = function (input, o) { if (li && evt.button === 0) { // Only select on left click evt.preventDefault(); - me.select(li, evt); + me.select(li, evt.target); } } }}); @@ -191,7 +191,7 @@ _.prototype = { $.fire(this.input, "awesomplete-highlight"); }, - select: function (selected, originalEvent) { + select: function (selected, origin) { selected = selected || this.ul.children[this.index]; if (selected) { @@ -202,7 +202,7 @@ _.prototype = { preventDefault: function () { prevented = true; }, - originalEvent: originalEvent + origin: origin || selected }); if (!prevented) { diff --git a/test/events/mousedownSpec.js b/test/events/mousedownSpec.js index da5427e..063ae62 100644 --- a/test/events/mousedownSpec.js +++ b/test/events/mousedownSpec.js @@ -31,7 +31,7 @@ describe("mousedown event", function () { describe("on left click", function () { it("selects item", function () { var event = $.fire(this.target, "mousedown", { button: 0 }); - expect(this.subject.select).toHaveBeenCalledWith(this.li, event); + expect(this.subject.select).toHaveBeenCalledWith(this.li, this.target); expect(event.defaultPrevented).toBe(true); }); }); @@ -49,7 +49,7 @@ describe("mousedown event", function () { it("selects item", function () { var event = $.fire(this.target, "mousedown", { button: 0 }); - expect(this.subject.select).toHaveBeenCalledWith(this.li, event); + expect(this.subject.select).toHaveBeenCalledWith(this.li, this.target); expect(event.defaultPrevented).toBe(true); }); }); |