Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9cb2195

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 15213ec commit 9cb2195

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
@@ -861,16 +861,21 @@ function $CompileProvider($provide) {
861861

862862

863863
function addAttrInterpolateDirective(node, directives, value, name) {
864-
var interpolateFn = $interpolate(value, true);
865-
if (SIDE_EFFECT_ATTRS[name]) {
866-
name = SIDE_EFFECT_ATTRS[name];
867-
if (isBooleanAttr(node, name)) {
868-
value = true;
869-
}
870-
} else if (!interpolateFn) {
871-
// we are not a side-effect attr, and we have no side-effects -> ignore
864+
var interpolateFn = $interpolate(value, true),
865+
realName = SIDE_EFFECT_ATTRS[name],
866+
specialAttrDir = (realName && (realName !== name));
867+
868+
realName = realName || name;
869+
870+
if (specialAttrDir && isBooleanAttr(node, name)) {
871+
value = true;
872+
}
873+
874+
// no interpolation found and we are not a side-effect attr -> ignore
875+
if (!interpolateFn && !specialAttrDir) {
872876
return;
873877
}
878+
874879
directives.push({
875880
priority: 100,
876881
compile: function(element, attr) {
@@ -884,14 +889,14 @@ function $CompileProvider($provide) {
884889

885890
// we define observers array only for interpolated attrs
886891
// and ignore observers for non interpolated attrs to save some memory
887-
attr.$observers[name] = [];
888-
attr[name] = undefined;
892+
attr.$observers[realName] = [];
893+
attr[realName] = undefined;
889894
scope.$watch(interpolateFn, function(value) {
890-
attr.$set(name, value);
895+
attr.$set(realName, value);
891896
});
892897
};
893898
} else {
894-
attr.$set(name, value);
899+
attr.$set(realName, value);
895900
}
896901
}
897902
});

0 commit comments

Comments
 (0)