@@ -618,6 +618,8 @@ function $RootScopeProvider(){
618
618
* - `name` - {string}: Name of the event.
619
619
* - `stopPropagation` - {function=}: calling `stopPropagation` function will cancel further event propagation
620
620
* (available only for events that were `$emit`-ed).
621
+ * - `preventDefault` - {function}: calling `preventDefault` sets `defaultPrevented` flag to true.
622
+ * - `defaultPrevented` - {boolean}: true if `preventDefault` was called.
621
623
*/
622
624
$on : function ( name , listener ) {
623
625
var namedListeners = this . $$listeners [ name ] ;
@@ -662,7 +664,11 @@ function $RootScopeProvider(){
662
664
event = {
663
665
name : name ,
664
666
targetScope : scope ,
665
- stopPropagation : function ( ) { stopPropagation = true ; }
667
+ stopPropagation : function ( ) { stopPropagation = true ; } ,
668
+ preventDefault : function ( ) {
669
+ event . defaultPrevented = true ;
670
+ } ,
671
+ defaultPrevented : false
666
672
} ,
667
673
listenerArgs = concat ( [ event ] , arguments , 1 ) ,
668
674
i , length ;
@@ -712,8 +718,14 @@ function $RootScopeProvider(){
712
718
var target = this ,
713
719
current = target ,
714
720
next = target ,
715
- event = { name : name ,
716
- targetScope : target } ,
721
+ event = {
722
+ name : name ,
723
+ targetScope : target ,
724
+ preventDefault : function ( ) {
725
+ event . defaultPrevented = true ;
726
+ } ,
727
+ defaultPrevented : false
728
+ } ,
717
729
listenerArgs = concat ( [ event ] , arguments , 1 ) ;
718
730
719
731
//down while you can, then up and next sibling or up and next sibling until back at root
0 commit comments