Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 566f101

Browse files
committed
perf(jqLite): optimize event listener registration
1 parent 274e9c4 commit 566f101

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/jqLite.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,17 @@ forEach({
784784
if (!events) jqLiteExpandoStore(element, 'events', events = {});
785785
if (!handle) jqLiteExpandoStore(element, 'handle', handle = createEventHandler(element, events));
786786

787-
forEach(type.split(' '), function(type){
787+
var types = type.split(' ');
788+
var i = types.length;
789+
790+
while (i--) {
791+
type = types[i];
788792
var eventFns = events[type];
789793

790794
if (!eventFns) {
791795
events[type] = [];
792796

793-
if (type == 'mouseenter' || type == 'mouseleave') {
797+
if (type === 'mouseenter' || type === 'mouseleave') {
794798
// Refer to jQuery's implementation of mouseenter & mouseleave
795799
// Read about mouseenter and mouseleave:
796800
// http://www.quirksmode.org/js/events_mouse.html#link8
@@ -810,7 +814,7 @@ forEach({
810814
eventFns = events[type];
811815
}
812816
eventFns.push(fn);
813-
});
817+
}
814818
},
815819

816820
off: jqLiteOff,

0 commit comments

Comments
 (0)