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