Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2c6aa4c

Browse files
shyamseshadrimhevery
authored andcommitted
fix(*): name all anonymous watch functions in Angular
This will allow us to see function names in Batarang and debugger. Closes #1119
1 parent f7a8f17 commit 2c6aa4c

File tree

17 files changed

+31
-30
lines changed

17 files changed

+31
-30
lines changed

docs/src/templates/js/docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
297297
tutorial: 'Tutorial',
298298
cookbook: 'Examples'
299299
};
300-
$scope.$watch(function() {return $location.path(); }, function(path) {
300+
$scope.$watch(function docsPathWatch() {return $location.path(); }, function docsPathWatchAction(path) {
301301
// ignore non-doc links which are used in examples
302302
if (DOCS_PATH.test(path)) {
303303
var parts = path.split('/'),

src/bootstrap/bootstrap-prettify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
210210
}, $delegate);
211211
}]);
212212
$provide.decorator('$rootScope', ['$delegate', function(embedRootScope) {
213-
docsRootScope.$watch(function() {
213+
docsRootScope.$watch(function embedRootScopeDigestWatch() {
214214
embedRootScope.$digest();
215215
});
216216
return embedRootScope;

src/bootstrap/bootstrap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ directive.dropdownToggle =
99
return {
1010
restrict: 'C',
1111
link: function(scope, element, attrs) {
12-
scope.$watch(function(){return $location.path();}, function() {
12+
scope.$watch(function dropdownTogglePathWatch(){return $location.path();}, function dropdownTogglePathWatchAction() {
1313
close && close();
1414
});
1515

src/ng/anchorScroll.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ function $AnchorScrollProvider() {
5555
// does not scroll when user clicks on anchor link that is currently on
5656
// (no url change, no $locaiton.hash() change), browser native does scroll
5757
if (autoScrollingEnabled) {
58-
$rootScope.$watch(function() {return $location.hash();}, function() {
59-
$rootScope.$evalAsync(scroll);
60-
});
58+
$rootScope.$watch(function autoScrollWatch() {return $location.hash();},
59+
function autoScrollWatchAction() {
60+
$rootScope.$evalAsync(scroll);
61+
});
6162
}
6263

6364
return scroll;

src/ng/compile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ function $CompileProvider($provide) {
737737
' (directive: ' + newScopeDirective.name + ')');
738738
};
739739
lastValue = scope[scopeName] = parentGet(parentScope);
740-
scope.$watch(function() {
740+
scope.$watch(function parentValueWatch() {
741741
var parentValue = parentGet(parentScope);
742742

743743
if (parentValue !== scope[scopeName]) {
@@ -996,7 +996,7 @@ function $CompileProvider($provide) {
996996
bindings = parent.data('$binding') || [];
997997
bindings.push(interpolateFn);
998998
safeAddClass(parent.data('$binding', bindings), 'ng-binding');
999-
scope.$watch(interpolateFn, function(value) {
999+
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
10001000
node[0].nodeValue = value;
10011001
});
10021002
})
@@ -1026,7 +1026,7 @@ function $CompileProvider($provide) {
10261026
attr[name] = undefined;
10271027
($$observers[name] || ($$observers[name] = [])).$$inter = true;
10281028
(attr.$$observers && attr.$$observers[name].$$scope || scope).
1029-
$watch(interpolateFn, function(value) {
1029+
$watch(interpolateFn, function interpolateFnWatchAction(value) {
10301030
attr.$set(name, value);
10311031
});
10321032
})

src/ng/directive/booleanAttrs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
284284
priority: 100,
285285
compile: function() {
286286
return function(scope, element, attr) {
287-
scope.$watch(attr[normalized], function(value) {
287+
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
288288
attr.$set(attrName, !!value);
289289
});
290290
};

src/ng/directive/input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
995995

996996
// model -> value
997997
var ctrl = this;
998-
$scope.$watch(ngModelGet, function(value) {
998+
$scope.$watch(ngModelGet, function ngModelWatchAction(value) {
999999

10001000
// ignore change from view
10011001
if (ctrl.$modelValue === value) return;
@@ -1242,7 +1242,7 @@ var ngValueDirective = function() {
12421242
};
12431243
} else {
12441244
return function(scope, elm, attr) {
1245-
scope.$watch(attr.ngValue, function(value) {
1245+
scope.$watch(attr.ngValue, function valueWatchAction(value) {
12461246
attr.$set('value', value, false);
12471247
});
12481248
};

src/ng/directive/ngBind.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
*/
5050
var ngBindDirective = ngDirective(function(scope, element, attr) {
5151
element.addClass('ng-binding').data('$binding', attr.ngBind);
52-
scope.$watch(attr.ngBind, function(value) {
52+
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
5353
element.text(value == undefined ? '' : value);
5454
});
5555
});
@@ -132,7 +132,7 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
132132
var ngBindHtmlUnsafeDirective = [function() {
133133
return function(scope, element, attr) {
134134
element.addClass('ng-binding').data('$binding', attr.ngBindHtmlUnsafe);
135-
scope.$watch(attr.ngBindHtmlUnsafe, function(value) {
135+
scope.$watch(attr.ngBindHtmlUnsafe, function ngBindHtmlUnsafeWatchAction(value) {
136136
element.html(value || '');
137137
});
138138
};

src/ng/directive/ngClass.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function classDirective(name, selector) {
44
name = 'ngClass' + name;
55
return ngDirective(function(scope, element, attr) {
66
// Reusable function for re-applying the ngClass
7-
function reapply(newVal, oldVal) {
7+
function ngClassWatchAction(newVal, oldVal) {
88
if (selector === true || scope.$index % 2 === selector) {
99
if (oldVal && (newVal !== oldVal)) {
1010
if (isObject(oldVal) && !isArray(oldVal))
@@ -16,11 +16,11 @@ function classDirective(name, selector) {
1616
if (newVal) element.addClass(isArray(newVal) ? newVal.join(' ') : newVal);
1717
}
1818
};
19-
scope.$watch(attr[name], reapply, true);
19+
scope.$watch(attr[name], ngClassWatchAction, true);
2020

2121
attr.$observe('class', function(value) {
2222
var ngClass = scope.$eval(attr[name]);
23-
reapply(ngClass, ngClass);
23+
ngClassWatchAction(ngClass, ngClass);
2424
});
2525
});
2626
}

src/ng/directive/ngInclude.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
101101
element.html('');
102102
};
103103

104-
scope.$watch(srcExp, function(src) {
104+
scope.$watch(srcExp, function ngIncludeWatchAction(src) {
105105
var thisChangeId = ++changeCounter;
106106

107107
if (src) {

0 commit comments

Comments
 (0)