Skip to content

Commit e43541f

Browse files
committed
perf(Scope): exit $broadcast early if nobody is listening for the given event
1 parent 7041d5b commit e43541f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ng/rootScope.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1137,8 +1137,11 @@ function $RootScopeProvider(){
11371137
event.defaultPrevented = true;
11381138
},
11391139
defaultPrevented: false
1140-
},
1141-
listenerArgs = concat([event], arguments, 1),
1140+
};
1141+
1142+
if (!target.$$listenerCount[name]) return event;
1143+
1144+
var listenerArgs = concat([event], arguments, 1),
11421145
listeners, i, length;
11431146

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

0 commit comments

Comments
 (0)