aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-04-07 17:24:24 -0700
committerMisko Hevery2010-04-07 17:24:24 -0700
commite0ad7dfcd47196d0aa9271e84b2c4ac26cfda3f4 (patch)
treef62565e7318ca6fe83520855292a29231b5f5970 /src
parenta8aa5af413c068608aa28ef0d48cef1d5ad66485 (diff)
downloadangular.js-e0ad7dfcd47196d0aa9271e84b2c4ac26cfda3f4.tar.bz2
seperatio validation and exception handling
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js5
-rw-r--r--src/directives.js7
-rw-r--r--src/services.js2
3 files changed, 9 insertions, 5 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 3b5e1c90..d8b03464 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -10,7 +10,6 @@ var consoleNode,
PRIORITY_WATCH = -1000,
PRIORITY_LAST = 99999,
NOOP = 'noop',
- NG_ERROR = 'ng-error',
NG_EXCEPTION = 'ng-exception',
NG_VALIDATION_ERROR = 'ng-validation-error',
jQuery = window['jQuery'] || window['$'], // weirdness to make IE happy
@@ -259,10 +258,10 @@ function elementError(element, type, error) {
}
if (error) {
element.addClass(type);
- element.attr(NG_ERROR, error);
+ element.attr(type, error);
} else {
element.removeClass(type);
- element.removeAttr(NG_ERROR);
+ element.removeAttr(type);
}
}
diff --git a/src/directives.js b/src/directives.js
index 5cee0978..22ff7544 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -80,12 +80,17 @@ angularDirective("ng-bind-template", function(expression){
};
});
+var REMOVE_ATTRIBUTES = {
+ 'disabled':true,
+ 'readonly':true,
+ 'checked':true
+};
angularDirective("ng-bind-attr", function(expression){
return function(element){
this.$onEval(function(){
foreach(this.$eval(expression), function(bindExp, key) {
var value = compileBindTemplate(bindExp).call(this, element);
- if (key == 'disabled' && !toBoolean(value)) {
+ if (REMOVE_ATTRIBUTES[lowercase(key)] && !toBoolean(value)) {
element.removeAttr('disabled');
} else {
element.attr(key, value);
diff --git a/src/services.js b/src/services.js
index 9d60f795..291e1704 100644
--- a/src/services.js
+++ b/src/services.js
@@ -47,7 +47,7 @@ angularService("$location", function(browser){
angularService("$hover", function(browser) {
var tooltip, self = this, error, width = 300, arrowWidth = 10;
browser.hover(function(element, show){
- if (show && (error = element.attr('ng-error'))) {
+ if (show && (error = element.attr(NG_EXCEPTION) || element.attr(NG_VALIDATION_ERROR))) {
if (!tooltip) {
tooltip = {
callout: jqLite('<div id="ng-callout"></div>'),