Skip to content

Commit

Permalink
Pass origin element to awesomplete-select instead of event
Browse files Browse the repository at this point in the history
  • Loading branch information
vlazar committed Jan 23, 2016
1 parent 8bbb86d commit 5abf4df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions awesomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}});
Expand Down Expand Up @@ -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) {
Expand All @@ -202,7 +202,7 @@ _.prototype = {
preventDefault: function () {
prevented = true;
},
originalEvent: originalEvent
origin: origin || selected
});

if (!prevented) {
Expand Down
4 changes: 2 additions & 2 deletions test/events/mousedownSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
Expand All @@ -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);
});
});
Expand Down

0 comments on commit 5abf4df

Please sign in to comment.