From e571a4e73a5cff4b585f1d5a39044f9747355e5d Mon Sep 17 00:00:00 2001 From: Tom Ashworth Date: Wed, 14 Jan 2015 18:00:17 +0000 Subject: [PATCH] Keep data.el alongside event.currentTarget --- lib/utils.js | 2 +- test/spec/utils_spec.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils.js b/lib/utils.js index 1f94772a..2e12ef1c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -239,7 +239,7 @@ define( Object.keys(rules).forEach(function(selector) { if (!e.isPropagationStopped() && (parent = target.closest(selector)).length) { data = data || {}; - e.currentTarget = parent[0]; + e.currentTarget = data.el = parent[0]; return rules[selector].apply(this, [e, data]); } }, this); diff --git a/test/spec/utils_spec.js b/test/spec/utils_spec.js index ceb49a61..845d88ea 100644 --- a/test/spec/utils_spec.js +++ b/test/spec/utils_spec.js @@ -255,7 +255,9 @@ define(['lib/component', 'lib/utils', 'lib/debug'], function (defineComponent, u $(document.body).trigger('click', myData); + var callbackArgs = spy.mostRecentCall.args; expect(spy).toHaveBeenCalledWith(jasmine.any($.Event), myData); + expect(callbackArgs[1].el).toBe(document.body); }); it('should pass the correct currentTarget', function () {