Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9cd6dc

Browse files
committed
perf(jqLite): improve createEventHandler method by switching from forEach to for loop
1 parent 960a841 commit e9cd6dc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/jqLite.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,9 @@ function createEventHandler(element, events) {
740740
// Copy event handlers in case event handlers array is modified during execution.
741741
var eventHandlersCopy = shallowCopy(events[type || event.type] || []);
742742

743-
forEach(eventHandlersCopy, function(fn) {
744-
fn.call(element, event);
745-
});
743+
for (var i = 0, ii = eventHandlersCopy.length; i < ii; i++) {
744+
eventHandlersCopy[i].call(element, event);
745+
}
746746

747747
// Remove monkey-patched methods (IE),
748748
// as they would cause memory leaks in IE8.

0 commit comments

Comments
 (0)