@@ -72,63 +72,74 @@ function decorateRootScope($delegate, $parse) {
72
72
} ) ;
73
73
} ;
74
74
75
- var debouncedEmit = debounceOn ( hint . emit , 10 , function ( params ) {
76
- return params . id + params . path ;
77
- } ) ;
78
-
79
-
80
75
var scopePrototype = ( 'getPrototypeOf' in Object ) ?
81
76
Object . getPrototypeOf ( $delegate ) : $delegate . __proto__ ;
82
77
83
- // var _watch = scopePrototype.$watch;
84
- // scopePrototype.$watch = function (watchExpression, reactionFunction) {
85
- // var watchStr = humanReadableWatchExpression (watchExpression);
86
- // var scopeId = this.$id ;
87
- // if (typeof watchExpression === 'function') {
88
- // arguments[0] = function ( ) {
89
- // var start = perf.now();
90
- // var ret = watchExpression.apply(this, arguments );
91
- // var end = perf.now( );
92
- // hint.emit('scope:watch', {
93
- // id: scopeId,
94
- // watch: watchStr ,
95
- // time: end - start
96
- // });
97
- // return ret;
98
- // } ;
99
- // } else {
100
- // var thatScope = this ;
101
- // arguments[0] = function () {
102
- // var start = perf.now() ;
103
- // var ret = thatScope.$eval(watchExpression);
104
- // var end = perf.now();
105
- // hint.emit('scope:watch', {
106
- // id: scopeId,
107
- // watch: watchStr,
108
- // time: end - start
109
- // });
110
- // return ret;
111
- // };
112
- // }
113
-
114
- // if (typeof reactionFunction === 'function') {
115
- // var applyStr = reactionFunction.toString();
116
- // arguments[1] = function () {
117
- // var start = perf.now();
118
- // var ret = reactionFunction.apply(this, arguments);
119
- // var end = perf.now();
120
- // hint.emit('scope:reaction', {
121
- // id: this.$id,
122
- // watch: watchStr,
123
- // time: end - start
124
- // });
125
- // return ret;
126
- // };
127
- // }
128
-
129
- // return _watch.apply(this, arguments) ;
130
- // };
78
+ var _watch = scopePrototype . $watch ;
79
+ var _digestEvents = [ ] ;
80
+ scopePrototype . $watch = function ( watchExpression , reactionFunction ) {
81
+ var watchStr = humanReadableWatchExpression ( watchExpression ) ;
82
+ var scopeId = this . $id ;
83
+ if ( typeof watchExpression === ' function' ) {
84
+ arguments [ 0 ] = function ( ) {
85
+ var start = perf . now ( ) ;
86
+ var ret = watchExpression . apply ( this , arguments ) ;
87
+ var end = perf . now ( ) ;
88
+ _digestEvents . push ( {
89
+ eventType : 'scope:watch' ,
90
+ id : scopeId ,
91
+ watch : watchStr ,
92
+ time : end - start
93
+ } ) ;
94
+ return ret ;
95
+ } ;
96
+ } else {
97
+ var thatScope = this ;
98
+ arguments [ 0 ] = function ( ) {
99
+ var start = perf . now ( ) ;
100
+ var ret = thatScope . $eval ( watchExpression ) ;
101
+ var end = perf . now ( ) ;
102
+ _digestEvents . push ( {
103
+ eventType : 'scope:watch' ,
104
+ id : scopeId ,
105
+ watch : watchStr ,
106
+ time : end - start
107
+ } ) ;
108
+ return ret ;
109
+ } ;
110
+ }
111
+
112
+ if ( typeof reactionFunction === 'function' ) {
113
+ arguments [ 1 ] = function ( ) {
114
+ var start = perf . now ( ) ;
115
+ var ret = reactionFunction . apply ( this , arguments ) ;
116
+ var end = perf . now ( ) ;
117
+ _digestEvents . push ( {
118
+ eventType : 'scope:reaction' ,
119
+ id : this . $id ,
120
+ watch : watchStr ,
121
+ time : end - start
122
+ } ) ;
123
+ return ret ;
124
+ } ;
125
+ }
131
126
127
+ return _watch . apply ( this , arguments ) ;
128
+ } ;
129
+
130
+ var _digest = scopePrototype . $digest ;
131
+ scopePrototype . $digest = function ( fn ) {
132
+ _digestEvents = [ ] ;
133
+ var start = perf . now ( ) ;
134
+ var ret = _digest . apply ( this , arguments ) ;
135
+ var end = perf . now ( ) ;
136
+ hint . emit ( 'scope:digest' , {
137
+ id : this . $id ,
138
+ time : end - start ,
139
+ events : _digestEvents
140
+ } ) ;
141
+ return ret ;
142
+ } ;
132
143
133
144
var _destroy = scopePrototype . $destroy ;
134
145
scopePrototype . $destroy = function ( ) {
@@ -180,17 +191,6 @@ function decorateRootScope($delegate, $parse) {
180
191
}
181
192
}
182
193
183
-
184
- // var _digest = scopePrototype.$digest;
185
- // scopePrototype.$digest = function (fn) {
186
- // var start = perf.now();
187
- // var ret = _digest.apply(this, arguments);
188
- // var end = perf.now();
189
- // hint.emit('scope:digest', { id: this.$id, time: end - start });
190
- // return ret;
191
- // };
192
-
193
-
194
194
var _apply = scopePrototype . $apply ;
195
195
scopePrototype . $apply = function ( fn ) {
196
196
// var start = perf.now();
@@ -255,7 +255,7 @@ function decorateDollaCompile ($delegate) {
255
255
descriptor : descriptor
256
256
} ) ;
257
257
return elt ;
258
- }
258
+ } ;
259
259
} ;
260
260
261
261
// TODO: test this
0 commit comments