mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
fix(*): name all anonymous watch functions in Angular
This will allow us to see function names in Batarang and debugger. Closes #1119
This commit is contained in:
parent
b6e4a71166
commit
ca30fce28c
17 changed files with 31 additions and 30 deletions
|
|
@ -297,7 +297,7 @@ docsApp.controller.DocsController = function($scope, $location, $window, $cookie
|
|||
tutorial: 'Tutorial',
|
||||
cookbook: 'Examples'
|
||||
};
|
||||
$scope.$watch(function() {return $location.path(); }, function(path) {
|
||||
$scope.$watch(function docsPathWatch() {return $location.path(); }, function docsPathWatchAction(path) {
|
||||
// ignore non-doc links which are used in examples
|
||||
if (DOCS_PATH.test(path)) {
|
||||
var parts = path.split('/'),
|
||||
|
|
|
|||
2
src/bootstrap/bootstrap-prettify.js
vendored
2
src/bootstrap/bootstrap-prettify.js
vendored
|
|
@ -210,7 +210,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
|
|||
}, $delegate);
|
||||
}]);
|
||||
$provide.decorator('$rootScope', ['$delegate', function(embedRootScope) {
|
||||
docsRootScope.$watch(function() {
|
||||
docsRootScope.$watch(function embedRootScopeDigestWatch() {
|
||||
embedRootScope.$digest();
|
||||
});
|
||||
return embedRootScope;
|
||||
|
|
|
|||
2
src/bootstrap/bootstrap.js
vendored
2
src/bootstrap/bootstrap.js
vendored
|
|
@ -9,7 +9,7 @@ directive.dropdownToggle =
|
|||
return {
|
||||
restrict: 'C',
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$watch(function(){return $location.path();}, function() {
|
||||
scope.$watch(function dropdownTogglePathWatch(){return $location.path();}, function dropdownTogglePathWatchAction() {
|
||||
close && close();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,10 @@ function $AnchorScrollProvider() {
|
|||
// does not scroll when user clicks on anchor link that is currently on
|
||||
// (no url change, no $locaiton.hash() change), browser native does scroll
|
||||
if (autoScrollingEnabled) {
|
||||
$rootScope.$watch(function() {return $location.hash();}, function() {
|
||||
$rootScope.$evalAsync(scroll);
|
||||
});
|
||||
$rootScope.$watch(function autoScrollWatch() {return $location.hash();},
|
||||
function autoScrollWatchAction() {
|
||||
$rootScope.$evalAsync(scroll);
|
||||
});
|
||||
}
|
||||
|
||||
return scroll;
|
||||
|
|
|
|||
|
|
@ -737,7 +737,7 @@ function $CompileProvider($provide) {
|
|||
' (directive: ' + newScopeDirective.name + ')');
|
||||
};
|
||||
lastValue = scope[scopeName] = parentGet(parentScope);
|
||||
scope.$watch(function() {
|
||||
scope.$watch(function parentValueWatch() {
|
||||
var parentValue = parentGet(parentScope);
|
||||
|
||||
if (parentValue !== scope[scopeName]) {
|
||||
|
|
@ -996,7 +996,7 @@ function $CompileProvider($provide) {
|
|||
bindings = parent.data('$binding') || [];
|
||||
bindings.push(interpolateFn);
|
||||
safeAddClass(parent.data('$binding', bindings), 'ng-binding');
|
||||
scope.$watch(interpolateFn, function(value) {
|
||||
scope.$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
||||
node[0].nodeValue = value;
|
||||
});
|
||||
})
|
||||
|
|
@ -1026,7 +1026,7 @@ function $CompileProvider($provide) {
|
|||
attr[name] = undefined;
|
||||
($$observers[name] || ($$observers[name] = [])).$$inter = true;
|
||||
(attr.$$observers && attr.$$observers[name].$$scope || scope).
|
||||
$watch(interpolateFn, function(value) {
|
||||
$watch(interpolateFn, function interpolateFnWatchAction(value) {
|
||||
attr.$set(name, value);
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
|
|||
priority: 100,
|
||||
compile: function() {
|
||||
return function(scope, element, attr) {
|
||||
scope.$watch(attr[normalized], function(value) {
|
||||
scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) {
|
||||
attr.$set(attrName, !!value);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1010,7 +1010,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
|
|||
|
||||
// model -> value
|
||||
var ctrl = this;
|
||||
$scope.$watch(ngModelGet, function(value) {
|
||||
$scope.$watch(ngModelGet, function ngModelWatchAction(value) {
|
||||
|
||||
// ignore change from view
|
||||
if (ctrl.$modelValue === value) return;
|
||||
|
|
@ -1257,7 +1257,7 @@ var ngValueDirective = function() {
|
|||
};
|
||||
} else {
|
||||
return function(scope, elm, attr) {
|
||||
scope.$watch(attr.ngValue, function(value) {
|
||||
scope.$watch(attr.ngValue, function valueWatchAction(value) {
|
||||
attr.$set('value', value, false);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
*/
|
||||
var ngBindDirective = ngDirective(function(scope, element, attr) {
|
||||
element.addClass('ng-binding').data('$binding', attr.ngBind);
|
||||
scope.$watch(attr.ngBind, function(value) {
|
||||
scope.$watch(attr.ngBind, function ngBindWatchAction(value) {
|
||||
element.text(value == undefined ? '' : value);
|
||||
});
|
||||
});
|
||||
|
|
@ -132,7 +132,7 @@ var ngBindTemplateDirective = ['$interpolate', function($interpolate) {
|
|||
var ngBindHtmlUnsafeDirective = [function() {
|
||||
return function(scope, element, attr) {
|
||||
element.addClass('ng-binding').data('$binding', attr.ngBindHtmlUnsafe);
|
||||
scope.$watch(attr.ngBindHtmlUnsafe, function(value) {
|
||||
scope.$watch(attr.ngBindHtmlUnsafe, function ngBindHtmlUnsafeWatchAction(value) {
|
||||
element.html(value || '');
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ function classDirective(name, selector) {
|
|||
name = 'ngClass' + name;
|
||||
return ngDirective(function(scope, element, attr) {
|
||||
// Reusable function for re-applying the ngClass
|
||||
function reapply(newVal, oldVal) {
|
||||
function ngClassWatchAction(newVal, oldVal) {
|
||||
if (selector === true || scope.$index % 2 === selector) {
|
||||
if (oldVal && (newVal !== oldVal)) {
|
||||
if (isObject(oldVal) && !isArray(oldVal))
|
||||
|
|
@ -16,11 +16,11 @@ function classDirective(name, selector) {
|
|||
if (newVal) element.addClass(isArray(newVal) ? newVal.join(' ') : newVal);
|
||||
}
|
||||
};
|
||||
scope.$watch(attr[name], reapply, true);
|
||||
scope.$watch(attr[name], ngClassWatchAction, true);
|
||||
|
||||
attr.$observe('class', function(value) {
|
||||
var ngClass = scope.$eval(attr[name]);
|
||||
reapply(ngClass, ngClass);
|
||||
ngClassWatchAction(ngClass, ngClass);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$compile'
|
|||
element.html('');
|
||||
};
|
||||
|
||||
scope.$watch(srcExp, function(src) {
|
||||
scope.$watch(srcExp, function ngIncludeWatchAction(src) {
|
||||
var thisChangeId = ++changeCounter;
|
||||
|
||||
if (src) {
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
|
|||
offset + endSymbol));
|
||||
});
|
||||
|
||||
scope.$watch(function() {
|
||||
scope.$watch(function ngPluralizeWatch() {
|
||||
var value = parseFloat(scope.$eval(numberExp));
|
||||
|
||||
if (!isNaN(value)) {
|
||||
|
|
@ -199,7 +199,7 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
|
|||
} else {
|
||||
return '';
|
||||
}
|
||||
}, function(newVal) {
|
||||
}, function ngPluralizeWatchAction(newVal) {
|
||||
element.text(newVal);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ var ngRepeatDirective = ngDirective({
|
|||
// We expect this to be a rare case.
|
||||
var lastOrder = new HashQueueMap();
|
||||
var indexValues = [];
|
||||
scope.$watch(function(scope){
|
||||
scope.$watch(function ngRepeatWatch(scope){
|
||||
var index, length,
|
||||
collection = scope.$eval(rhs),
|
||||
collectionLength = size(collection, true),
|
||||
|
|
@ -131,7 +131,7 @@ var ngRepeatDirective = ngDirective({
|
|||
} else {
|
||||
last = undefined;
|
||||
}
|
||||
|
||||
|
||||
if (last) {
|
||||
// if we have already seen this object, then we need to reuse the
|
||||
// associated scope/element
|
||||
|
|
@ -187,7 +187,7 @@ var ngRepeatDirective = ngDirective({
|
|||
for (i = 0, l = indexValues.length - length; i < l; i++) {
|
||||
indexValues.pop();
|
||||
}
|
||||
|
||||
|
||||
//shrink children
|
||||
for (key in lastOrder) {
|
||||
if (lastOrder.hasOwnProperty(key)) {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
//TODO(misko): refactor to remove element from the DOM
|
||||
var ngShowDirective = ngDirective(function(scope, element, attr){
|
||||
scope.$watch(attr.ngShow, function(value){
|
||||
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
|
||||
element.css('display', toBoolean(value) ? '' : 'none');
|
||||
});
|
||||
});
|
||||
|
|
@ -74,7 +74,7 @@ var ngShowDirective = ngDirective(function(scope, element, attr){
|
|||
*/
|
||||
//TODO(misko): refactor to remove element from the DOM
|
||||
var ngHideDirective = ngDirective(function(scope, element, attr){
|
||||
scope.$watch(attr.ngHide, function(value){
|
||||
scope.$watch(attr.ngHide, function ngHideWatchAction(value){
|
||||
element.css('display', toBoolean(value) ? 'none' : '');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
</example>
|
||||
*/
|
||||
var ngStyleDirective = ngDirective(function(scope, element, attr) {
|
||||
scope.$watch(attr.ngStyle, function(newStyles, oldStyles) {
|
||||
scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) {
|
||||
if (oldStyles && (newStyles !== oldStyles)) {
|
||||
forEach(oldStyles, function(val, style) { element.css(style, '');});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ var ngSwitchDirective = valueFn({
|
|||
selectedElement,
|
||||
selectedScope;
|
||||
|
||||
scope.$watch(watchExpr, function(value) {
|
||||
scope.$watch(watchExpr, function ngSwitchWatchAction(value) {
|
||||
if (selectedElement) {
|
||||
selectedScope.$destroy();
|
||||
selectedElement.remove();
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
|
|||
|
||||
// we have to do it on each watch since ngModel watches reference, but
|
||||
// we need to work of an array, so we need to see if anything was inserted/removed
|
||||
scope.$watch(function() {
|
||||
scope.$watch(function selectMultipleWatch() {
|
||||
if (!equals(lastView, ctrl.$viewValue)) {
|
||||
lastView = copy(ctrl.$viewValue);
|
||||
ctrl.$render();
|
||||
|
|
@ -544,7 +544,7 @@ var optionDirective = ['$interpolate', function($interpolate) {
|
|||
}
|
||||
|
||||
if (interpolateFn) {
|
||||
scope.$watch(interpolateFn, function(newVal, oldVal) {
|
||||
scope.$watch(interpolateFn, function interpolateWatchAction(newVal, oldVal) {
|
||||
attr.$set('value', newVal);
|
||||
if (newVal !== oldVal) selectCtrl.removeOption(oldVal);
|
||||
selectCtrl.addOption(newVal);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
angular.module('ngSanitize').directive('ngBindHtml', ['$sanitize', function($sanitize) {
|
||||
return function(scope, element, attr) {
|
||||
element.addClass('ng-binding').data('$binding', attr.ngBindHtml);
|
||||
scope.$watch(attr.ngBindHtml, function(value) {
|
||||
scope.$watch(attr.ngBindHtml, function ngBindHtmlWatchAction(value) {
|
||||
value = $sanitize(value);
|
||||
element.html(value || '');
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue