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

Skip to content

Commit a09fa35

Browse files
committed
perf(Scope): exit $broadcast early if nobody is listening for the given event
1 parent 36e35b2 commit a09fa35

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ng/rootScope.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,11 @@ function $RootScopeProvider(){
11481148
event.defaultPrevented = true;
11491149
},
11501150
defaultPrevented: false
1151-
},
1152-
listenerArgs = concat([event], arguments, 1),
1151+
};
1152+
1153+
if (!target.$$listenerCount[name]) return event;
1154+
1155+
var listenerArgs = concat([event], arguments, 1),
11531156
listeners, i, length;
11541157

11551158
//down while you can, then up and next sibling or up and next sibling until back at root

0 commit comments

Comments
 (0)