Skip to content

Commit

Permalink
Merge pull request facebook#1511 from syranide/strsidefx
Browse files Browse the repository at this point in the history
HAS_SIDE_EFFECTS should compare by type-casting
  • Loading branch information
chenglou committed Jul 24, 2014
2 parents f76d4dd + 3b94abc commit 7f584f3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/browser/ui/dom/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,17 @@ var DOMPropertyOperations = {
} else if (shouldIgnoreValue(name, value)) {
this.deleteValueForProperty(node, name);
} else if (DOMProperty.mustUseAttribute[name]) {
// `setAttribute` with objects becomes only `[object]` in IE8/9,
// ('' + value) makes it output the correct toString()-value.
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
} else {
var propName = DOMProperty.getPropertyName[name];
if (!DOMProperty.hasSideEffects[name] || node[propName] !== value) {
// Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
// property type before comparing; only `value` does and is string.
if (!DOMProperty.hasSideEffects[name] ||
('' + node[propName]) !== ('' + value)) {
// Contrary to `setAttribute`, object properties are properly
// `toString`ed by IE8/9.
node[propName] = value;
}
}
Expand Down Expand Up @@ -177,7 +184,7 @@ var DOMPropertyOperations = {
propName
);
if (!DOMProperty.hasSideEffects[name] ||
node[propName] !== defaultValue) {
('' + node[propName]) !== defaultValue) {
node[propName] = defaultValue;
}
}
Expand Down

0 comments on commit 7f584f3

Please sign in to comment.