aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2012-03-20 00:00:09 -0700
committerIgor Minar2012-03-20 11:07:36 -0700
commit9cb2195e61a78e99020ec19d687a221ca88b5900 (patch)
treecb78f403cc6811b05e30fddcac6f664065c47cab
parent15213ec212769837cb2b7e781ffc5bfd598d27ca (diff)
downloadangular.js-9cb2195e61a78e99020ec19d687a221ca88b5900.tar.bz2
fix($compile): don't touch static element attributes
Compiler should not reassign values to element attributes if its not neccessary due to interpolation or special attribute magic (ng-src -> src) This resolves several issues on IE caused by reassigning script.src attribute which caused all of the scripts to be reloaded.
-rw-r--r--src/service/compiler.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/service/compiler.js b/src/service/compiler.js
index 85566f3c..784b8a3c 100644
--- a/src/service/compiler.js
+++ b/src/service/compiler.js
@@ -861,16 +861,21 @@ function $CompileProvider($provide) {
function addAttrInterpolateDirective(node, directives, value, name) {
- var interpolateFn = $interpolate(value, true);
- if (SIDE_EFFECT_ATTRS[name]) {
- name = SIDE_EFFECT_ATTRS[name];
- if (isBooleanAttr(node, name)) {
- value = true;
- }
- } else if (!interpolateFn) {
- // we are not a side-effect attr, and we have no side-effects -> ignore
+ var interpolateFn = $interpolate(value, true),
+ realName = SIDE_EFFECT_ATTRS[name],
+ specialAttrDir = (realName && (realName !== name));
+
+ realName = realName || name;
+
+ if (specialAttrDir && isBooleanAttr(node, name)) {
+ value = true;
+ }
+
+ // no interpolation found and we are not a side-effect attr -> ignore
+ if (!interpolateFn && !specialAttrDir) {
return;
}
+
directives.push({
priority: 100,
compile: function(element, attr) {
@@ -884,14 +889,14 @@ function $CompileProvider($provide) {
// we define observers array only for interpolated attrs
// and ignore observers for non interpolated attrs to save some memory
- attr.$observers[name] = [];
- attr[name] = undefined;
+ attr.$observers[realName] = [];
+ attr[realName] = undefined;
scope.$watch(interpolateFn, function(value) {
- attr.$set(name, value);
+ attr.$set(realName, value);
});
};
} else {
- attr.$set(name, value);
+ attr.$set(realName, value);
}
}
});