HAS_SIDE_EFFECTS properties must compare as property type
Andreas Svensson committed
May 11, 2014 at 00:56 UTC
3b94abcb3b2c05fc38406b02a501427e58377c44
1 file changed
+9
-2
src/browser/ui/dom/DOMPropertyOperations.js
+9
-2
@@ -130,10 +130,17 @@ var DOMPropertyOperations = {
130
} else if (shouldIgnoreValue(name, value)) {
131
this.deleteValueForProperty(node, name);
132
} else if (DOMProperty.mustUseAttribute[name]) {
133
+ // `setAttribute` with objects becomes only `[object]` in IE8/9,
134
+ // ('' + value) makes it output the correct toString()-value.
135
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
136
} else {
137
var propName = DOMProperty.getPropertyName[name];
136
- if (!DOMProperty.hasSideEffects[name] || node[propName] !== value) {
138
+ // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
139
+ // property type before comparing; only `value` does and is string.
140
+ if (!DOMProperty.hasSideEffects[name] ||
141
+ ('' + node[propName]) !== ('' + value)) {
142
+ // Contrary to `setAttribute`, object properties are properly
143
+ // `toString`ed by IE8/9.
144
node[propName] = value;
145
}
146
}
@@ -168,7 +175,7 @@ var DOMPropertyOperations = {
175
propName
176
);
177
if (!DOMProperty.hasSideEffects[name] ||
171
- node[propName] !== defaultValue) {
178
+ ('' + node[propName]) !== defaultValue) {
179
node[propName] = defaultValue;
180
}
181
}