diff options
| author | Chris Chua | 2013-11-24 14:40:46 -0800 |
|---|---|---|
| committer | Vojta Jina | 2013-12-16 16:39:13 -0800 |
| commit | 2f91cfd0d2986899c38641100c1851b2f9d3888a (patch) | |
| tree | 944561843e11e07bfd0d2986c5560539eabde3e0 /src/jqLite.js | |
| parent | d5c5e2b5848dcb312390549a92c94c76822a5f4f (diff) | |
| download | angular.js-2f91cfd0d2986899c38641100c1851b2f9d3888a.tar.bz2 | |
fix(jqLite): support unbind self within handler
If an event handler unbinds itself, the next event handler on the same
event and element doesn't get executed.
This works fine in jQuery, and since jqLite doesn't support .one, this
might be a common use case.
Diffstat (limited to 'src/jqLite.js')
| -rw-r--r-- | src/jqLite.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/jqLite.js b/src/jqLite.js index 8a45f966..c1b5b36e 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -645,7 +645,10 @@ function createEventHandler(element, events) { return event.defaultPrevented || event.returnValue === false; }; - forEach(events[type || event.type], function(fn) { + // Copy event handlers in case event handlers array is modified during execution. + var eventHandlersCopy = shallowCopy(events[type || event.type] || []); + + forEach(eventHandlersCopy, function(fn) { fn.call(element, event); }); |
