don't try to use Object.prototype methods as transfer strategies in ReactPropTransferer.mergeProps

While looking up a detail of how `transferPropsTo()` works I noticed that we never check `TransferStrategies.hasOwnProperty(thisKey)` when merging props, just `newProps.hasOwnProperty(thisKey)` and a truthy test for `TransferStrategies[thisKey]`. This means that if our `newProps` has keys like `toString`, `valueOf`, or `constructor` etc. set, we will pull these functions off `TransferStrategies` and invoke them when merging props. In most cases this will just result in a failure to merge and some code without side effects being run but in the case of `valueOf` it will actually generate an exception.
This commit is contained in:
Andrew Zich
2014-03-18 15:01:46 -07:00
committed by Paul O’Shannessy
parent 0278f01d95
commit 22057ef61c
+1 -1
View File
@@ -95,7 +95,7 @@ var ReactPropTransferer = {
var transferStrategy = TransferStrategies[thisKey];
if (transferStrategy) {
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
transferStrategy(props, thisKey, newProps[thisKey]);
} else if (!props.hasOwnProperty(thisKey)) {
props[thisKey] = newProps[thisKey];