diff options
| author | Shyam Seshadri | 2012-07-06 15:23:40 +0530 | 
|---|---|---|
| committer | Misko Hevery | 2012-09-06 16:06:25 -0700 | 
| commit | ca30fce28ca13284bfa1c926e810ed75cdcde499 (patch) | |
| tree | e7e2a41e740312981fab5f1226f8bd1d98b07e62 | |
| parent | b6e4a71166c7f00f4140fd7ea8f0cd81b4487a3f (diff) | |
| download | angular.js-ca30fce28ca13284bfa1c926e810ed75cdcde499.tar.bz2 | |
fix(*): name all anonymous watch functions in Angular
This will allow us to see function names in Batarang and debugger.
Closes #1119
| -rw-r--r-- | docs/src/templates/js/docs.js | 2 | ||||
| -rw-r--r-- | src/bootstrap/bootstrap-prettify.js | 2 | ||||
| -rw-r--r-- | src/bootstrap/bootstrap.js | 2 | ||||
| -rw-r--r-- | src/ng/anchorScroll.js | 7 | ||||
| -rw-r--r-- | src/ng/compile.js | 6 | ||||
| -rw-r--r-- | src/ng/directive/booleanAttrs.js | 2 | ||||
| -rw-r--r-- | src/ng/directive/input.js | 4 | ||||
| -rw-r--r-- | src/ng/directive/ngBind.js | 4 | ||||
| -rw-r--r-- | src/ng/directive/ngClass.js | 6 | ||||
| -rw-r--r-- | src/ng/directive/ngInclude.js | 2 | ||||
| -rw-r--r-- | src/ng/directive/ngPluralize.js | 4 | ||||
| -rw-r--r-- | src/ng/directive/ngRepeat.js | 6 | ||||
| -rw-r--r-- | src/ng/directive/ngShowHide.js | 4 | ||||
| -rw-r--r-- | src/ng/directive/ngStyle.js | 2 | ||||
| -rw-r--r-- | src/ng/directive/ngSwitch.js | 2 | ||||
| -rw-r--r-- | src/ng/directive/select.js | 4 | ||||
| -rw-r--r-- | src/ngSanitize/directive/ngBindHtml.js | 2 | 
17 files changed, 31 insertions, 30 deletions
| diff --git a/docs/src/templates/js/docs.js b/docs/src/templates/js/docs.js index 436651e7..9813c241 100644 --- a/docs/src/templates/js/docs.js +++ b/docs/src/templates/js/docs.js @@ -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('/'), diff --git a/src/bootstrap/bootstrap-prettify.js b/src/bootstrap/bootstrap-prettify.js index b458c832..821d690f 100644 --- a/src/bootstrap/bootstrap-prettify.js +++ b/src/bootstrap/bootstrap-prettify.js @@ -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; diff --git a/src/bootstrap/bootstrap.js b/src/bootstrap/bootstrap.js index 8a398ad3..d21ed941 100644 --- a/src/bootstrap/bootstrap.js +++ b/src/bootstrap/bootstrap.js @@ -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();          }); diff --git a/src/ng/anchorScroll.js b/src/ng/anchorScroll.js index ecaa62e0..87867589 100644 --- a/src/ng/anchorScroll.js +++ b/src/ng/anchorScroll.js @@ -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; diff --git a/src/ng/compile.js b/src/ng/compile.js index a569ca8e..ccdd1880 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -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);              });          }) diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js index 2cc26ce7..8902c35d 100644 --- a/src/ng/directive/booleanAttrs.js +++ b/src/ng/directive/booleanAttrs.js @@ -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);            });          }; diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 412d768d..aba5ff1a 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -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);            });          }; diff --git a/src/ng/directive/ngBind.js b/src/ng/directive/ngBind.js index 70f25370..0c99f27d 100644 --- a/src/ng/directive/ngBind.js +++ b/src/ng/directive/ngBind.js @@ -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 || '');      });    }; diff --git a/src/ng/directive/ngClass.js b/src/ng/directive/ngClass.js index 6ba73e60..13b0378a 100644 --- a/src/ng/directive/ngClass.js +++ b/src/ng/directive/ngClass.js @@ -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);      });    });  } diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index 26107206..d4eacbe3 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -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) { diff --git a/src/ng/directive/ngPluralize.js b/src/ng/directive/ngPluralize.js index d9327b82..3938d4e3 100644 --- a/src/ng/directive/ngPluralize.js +++ b/src/ng/directive/ngPluralize.js @@ -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);        });      } diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index a47b7abc..021845fa 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -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)) { diff --git a/src/ng/directive/ngShowHide.js b/src/ng/directive/ngShowHide.js index e381c1b7..cba6cc89 100644 --- a/src/ng/directive/ngShowHide.js +++ b/src/ng/directive/ngShowHide.js @@ -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' : '');    });  }); diff --git a/src/ng/directive/ngStyle.js b/src/ng/directive/ngStyle.js index 5b0a3728..a1c2b699 100644 --- a/src/ng/directive/ngStyle.js +++ b/src/ng/directive/ngStyle.js @@ -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, '');});      } diff --git a/src/ng/directive/ngSwitch.js b/src/ng/directive/ngSwitch.js index 7d4cc192..0c9e2a8d 100644 --- a/src/ng/directive/ngSwitch.js +++ b/src/ng/directive/ngSwitch.js @@ -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(); diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 77b2f46d..0c94ddcb 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -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); diff --git a/src/ngSanitize/directive/ngBindHtml.js b/src/ngSanitize/directive/ngBindHtml.js index 346acff0..150e6bdc 100644 --- a/src/ngSanitize/directive/ngBindHtml.js +++ b/src/ngSanitize/directive/ngBindHtml.js @@ -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 || '');      }); | 
