aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive
diff options
context:
space:
mode:
authorMisko Hevery2012-06-04 15:06:02 -0700
committerIgor Minar2012-06-08 15:27:03 -0700
commit9be82d942fc6ab2772197c84a35a4c374c604cbc (patch)
tree9d59b22537cd5eefbd5419ca6eeda363b437f42c /src/ng/directive
parent2491319575f26fa8247b247247e223d5822ee61c (diff)
downloadangular.js-9be82d942fc6ab2772197c84a35a4c374c604cbc.tar.bz2
refactor($compile): always call attr.$observe
attr.$observe used to call function only if there was interpolation on that attribute. We now call the observation function all the time but we only save the reference to it if interpolation is present.
Diffstat (limited to 'src/ng/directive')
-rw-r--r--src/ng/directive/booleanAttrs.js29
-rw-r--r--src/ng/directive/input.js1
2 files changed, 8 insertions, 22 deletions
diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js
index 1468008c..b0c1b78f 100644
--- a/src/ng/directive/booleanAttrs.js
+++ b/src/ng/directive/booleanAttrs.js
@@ -284,7 +284,6 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) {
priority: 100,
compile: function() {
return function(scope, element, attr) {
- attr.$$observers[attrName] = [];
scope.$watch(attr[normalized], function(value) {
attr.$set(attrName, !!value);
});
@@ -301,27 +300,15 @@ forEach(['src', 'href'], function(attrName) {
ngAttributeAliasDirectives[normalized] = function() {
return {
priority: 99, // it needs to run after the attributes are interpolated
- compile: function() {
- return function(scope, element, attr) {
- var value = attr[normalized];
- if (value == undefined) {
- // undefined value means that the directive is being interpolated
- // so just register observer
- attr.$$observers[attrName] = [];
- attr.$observe(normalized, function(value) {
- attr.$set(attrName, value);
+ link: function(scope, element, attr) {
+ attr.$observe(normalized, function(value) {
+ attr.$set(attrName, value);
- // on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist
- // then calling element.setAttribute('src', 'foo') doesn't do anything, so we need
- // to set the property as well to achieve the desired effect
- if (msie) element.prop(attrName, value);
- });
- } else {
- // value present means that no interpolation, so copy to native attribute.
- attr.$set(attrName, value);
- element.prop(attrName, value);
- }
- };
+ // on IE, if "ng:src" directive declaration is used and "src" attribute doesn't exist
+ // then calling element.setAttribute('src', 'foo') doesn't do anything, so we need
+ // to set the property as well to achieve the desired effect
+ if (msie) element.prop(attrName, value);
+ });
}
};
};
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 5fe32125..aa79082b 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -1239,7 +1239,6 @@ var ngValueDirective = function() {
};
} else {
return function(scope, elm, attr) {
- attr.$$observers.value = [];
scope.$watch(attr.ngValue, function(value) {
attr.$set('value', value, false);
});