perf(jqLite): improve createEventHandler method by switching from forEach to for loop

This commit is contained in:
Igor Minar
2014-08-04 21:01:41 -07:00
parent 960a841051
commit e9cd6dc055

View File

@@ -740,9 +740,9 @@ function createEventHandler(element, events) {
// 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);
});
for (var i = 0, ii = eventHandlersCopy.length; i < ii; i++) {
eventHandlersCopy[i].call(element, event);
}
// Remove monkey-patched methods (IE),
// as they would cause memory leaks in IE8.