Skip to content

Commit 400f913

Browse files
committed
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.
1 parent ad97336 commit 400f913

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/service/compiler.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -858,31 +858,36 @@ function $CompileProvider($provide) {
858858

859859

860860
function addAttrInterpolateDirective(node, directives, value, name) {
861-
var interpolateFn = $interpolate(value, true);
862-
if (SIDE_EFFECT_ATTRS[name]) {
863-
name = SIDE_EFFECT_ATTRS[name];
864-
if (isBooleanAttr(node, name)) {
865-
value = true;
866-
}
867-
} else if (!interpolateFn) {
868-
// we are not a side-effect attr, and we have no side-effects -> ignore
861+
var interpolateFn = $interpolate(value, true),
862+
realName = SIDE_EFFECT_ATTRS[name],
863+
specialAttrDir = (realName && (realName !== name));
864+
865+
realName = realName || name;
866+
867+
if (specialAttrDir && isBooleanAttr(node, name)) {
868+
value = true;
869+
}
870+
871+
// no interpolation found and we are not a side-effect attr -> ignore
872+
if (!interpolateFn && !specialAttrDir) {
869873
return;
870874
}
875+
871876
directives.push({
872877
priority: 100,
873878
compile: function(element, attr) {
874879
if (interpolateFn) {
875880
return function(scope, element, attr) {
876881
// we define observers array only for interpolated attrs
877882
// and ignore observers for non interpolated attrs to save some memory
878-
attr.$observers[name] = [];
879-
attr[name] = undefined;
883+
attr.$observers[realName] = [];
884+
attr[realName] = undefined;
880885
scope.$watch(interpolateFn, function(value) {
881-
attr.$set(name, value);
886+
attr.$set(realName, value);
882887
});
883888
};
884889
} else {
885-
attr.$set(name, value);
890+
attr.$set(realName, value);
886891
}
887892
}
888893
});

0 commit comments

Comments
 (0)