diff options
| author | Misko Hevery | 2010-05-30 16:34:59 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-05-30 16:34:59 -0700 |
| commit | c7d64f6d124f10c66309042c2d77896215ed43b8 (patch) | |
| tree | b8127077d89d377dca17e70bba311f691424d5d1 /src | |
| parent | 0d87208553af7a9ad6c6c1c73bd3a4105062eafa (diff) | |
| download | angular.js-c7d64f6d124f10c66309042c2d77896215ed43b8.tar.bz2 | |
improve error handling with elements
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 15 | ||||
| -rw-r--r-- | src/Browser.js | 2 | ||||
| -rw-r--r-- | src/Scope.js | 8 | ||||
| -rw-r--r-- | src/apis.js | 3 |
4 files changed, 13 insertions, 15 deletions
diff --git a/src/Angular.js b/src/Angular.js index 8675bc40..39e9b385 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -291,12 +291,15 @@ function elementError(element, type, error) { while (!isRenderableElement(element)) { element = element.parent() || jqLite(document.body); } - if (error) { - element.addClass(type); - element.attr(type, error); - } else { - element.removeClass(type); - element.removeAttr(type); + if (element[0]['$NG_ERROR'] !== error) { + element[0]['$NG_ERROR'] = error; + if (error) { + element.addClass(type); + element.attr(type, error); + } else { + element.removeClass(type); + element.removeAttr(type); + } } } diff --git a/src/Browser.js b/src/Browser.js index 0e265c0c..0552b3ae 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -3,7 +3,7 @@ ////////////////////////////// function Browser(location, document) { - this.delay = 25; + this.delay = 50; this.expectedUrl = location.href; this.urlListeners = []; this.hoverListener = noop; diff --git a/src/Scope.js b/src/Scope.js index ac07c7a4..6d68eeed 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -53,14 +53,8 @@ function expressionCompile(exp){ parser.assertAllConsumed(); compileCache[exp] = expFn; } - return parserNewScopeAdapter(expFn); -} - -// return expFn -// TODO(remove this hack) -function parserNewScopeAdapter(fn) { return function(){ - return fn(this); + return expFn(this); }; } diff --git a/src/apis.js b/src/apis.js index 166ca27c..fda28346 100644 --- a/src/apis.js +++ b/src/apis.js @@ -296,8 +296,9 @@ var angularFunction = { if (isFunction(expression)){ return expression; } else if (expression){ + var fn = expressionCompile(expression); return function($) { - return expressionCompile(expression).apply($); + return fn.apply($); }; } else { return identity; |
