From f25e422417432b59126e2c21faa53d5b67da9be3 Mon Sep 17 00:00:00 2001 From: Wojciech Ogrodowczyk Date: Thu, 10 Nov 2016 00:15:05 -0800 Subject: [PATCH] Disallow object assign explanation Summary: > Explain the **motivation** for making this change. What existing problem does the pull request solve? Provides better documentation for a confusing (and common) error message. Solves https://github.com/facebook/react-native/issues/3634 > **Test plan (required)** This is just an error message shown in dev environment. I ran the tests and they pass. Closes https://github.com/facebook/react-native/pull/10472 Differential Revision: D4053818 Pulled By: hramos fbshipit-source-id: e80dc6ab787a8d8cabbcb442c438c07269401ff7 --- packager/react-packager/src/Resolver/polyfills/polyfills.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packager/react-packager/src/Resolver/polyfills/polyfills.js b/packager/react-packager/src/Resolver/polyfills/polyfills.js index 5652334218..c625f9ef63 100644 --- a/packager/react-packager/src/Resolver/polyfills/polyfills.js +++ b/packager/react-packager/src/Resolver/polyfills/polyfills.js @@ -15,6 +15,7 @@ // WARNING: This is an optimized version that fails on hasOwnProperty checks // and non objects. It's not spec-compliant. It's a perf optimization. +// This is only needed for iOS 8 and current Android JSC. /* eslint strict:0 */ Object.assign = function(target, sources) { if (__DEV__) { @@ -55,7 +56,8 @@ Object.assign = function(target, sources) { if (!hasOwnProperty.call(nextSource, key)) { throw new TypeError( 'One of the sources for assign has an enumerable key on the ' + - 'prototype chain. This is an edge case that we do not support. ' + + 'prototype chain. Are you trying to assign a prototype property? ' + + 'We don\'t allow it, as this is an edge case that we do not support. ' + 'This error is a performance optimization and not spec compliant.' ); }