This repository was archived by the owner on Apr 4, 2025. It is now read-only.
File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,19 @@ function ngEventDirectivesDecorator(ngEventAttrName) {
48
48
return function ngEventHandler ( scope , element , attrs ) {
49
49
var boundFuncs = getFunctionNames ( attrs [ ngEventAttrName ] ) ;
50
50
boundFuncs . forEach ( function ( boundFn ) {
51
- if ( $parse ( boundFn ) ( scope ) === undefined ) {
52
- angular . hint . log ( MODULE_NAME , boundFn + ' is undefined' ) ;
51
+ var property , propChain , lastProp = '' ;
52
+ while ( ( property = boundFn . match ( / ^ .+ ?( [ ^ \. \[ ] ) * / ) ) !== null ) {
53
+ property = property [ 0 ] ;
54
+ propChain = lastProp + property ;
55
+ if ( $parse ( propChain ) ( scope ) === undefined ) {
56
+ angular . hint . log ( MODULE_NAME , propChain + ' is undefined' ) ;
57
+ }
58
+ boundFn = boundFn . replace ( property , '' ) ;
59
+ lastProp += property ;
60
+ if ( boundFn . charAt ( 0 ) === '.' ) {
61
+ lastProp += '.' ;
62
+ boundFn = boundFn . substr ( 1 ) ;
63
+ }
53
64
}
54
65
} ) ;
55
66
Original file line number Diff line number Diff line change @@ -26,14 +26,28 @@ describe('hintEvents', function() {
26
26
} ) ;
27
27
28
28
// TODO: implement this
29
- xit ( 'should log a message if the path to handle an ng-event is not found' , function ( ) {
29
+ it ( 'should log a message if the path to handle an ng-event is not found' , function ( ) {
30
30
var elt = angular . element ( '<button ng-click="a.b.c()">Fake Increment</button>' ) ;
31
31
$compile ( elt ) ( $rootScope ) ;
32
32
$rootScope . a = { } ;
33
33
34
34
$rootScope . $digest ( ) ;
35
35
elt . triggerHandler ( 'click' ) ;
36
+ // expect(angular.hint.log).not.toHaveBeenCalledWith('Events', 'a is undefined');
36
37
expect ( angular . hint . log ) . toHaveBeenCalledWith ( 'Events' , 'a.b is undefined' ) ;
38
+ expect ( angular . hint . log ) . toHaveBeenCalledWith ( 'Events' , 'a.b.c is undefined' ) ;
39
+ } ) ;
40
+
41
+ it ( 'should log a message if the path to handle an ng-event with array syntax is not found' , function ( ) {
42
+ var elt = angular . element ( '<button ng-click="a[\'b\'].c()">Fake Increment</button>' ) ;
43
+ $compile ( elt ) ( $rootScope ) ;
44
+ $rootScope . a = { } ;
45
+
46
+ $rootScope . $digest ( ) ;
47
+ elt . triggerHandler ( 'click' ) ;
48
+ // expect(angular.hint.log).not.toHaveBeenCalledWith('Events', 'a is undefined');
49
+ expect ( angular . hint . log ) . toHaveBeenCalledWith ( 'Events' , 'a[\'b\'] is undefined' ) ;
50
+ expect ( angular . hint . log ) . toHaveBeenCalledWith ( 'Events' , 'a[\'b\'].c is undefined' ) ;
37
51
} ) ;
38
52
39
53
You can’t perform that action at this time.
0 commit comments