-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check in a forked version of object-assign only for UMD builds (#18180)
* Check in a forked version of object-assign This one uses ES modules so that we can inline it into UMD builds. We could wait for object-assign to make an ESM export but we're going to remove this dependency and assume global polyfills in the next version anyway. However, we'd have to figure out how to keep the copyright header and it'll get counted in terms of byte size (even if other tooling removes it). A lot of headache when we have our own implementation anyway. So I'll just use that. Ours is not resilient to checking certain browser bugs but those browsers are mostly unused anyway. (Even FB breaks on them presumably.) We also don't need to be resilient to Symbols since the way React uses it we shouldn't need to copy symbols * Don't transpile Object.assign to object-assign in object-assign The polyfill needs to be able to feature detect Object.assign.
- Loading branch information
1 parent
053347e
commit 58eedbb
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2004-present Facebook. All Rights Reserved. | ||
*/ | ||
|
||
const hasOwnProperty = Object.prototype.hasOwnProperty; | ||
|
||
const _assign = function(to, from) { | ||
for (let key in from) { | ||
if (hasOwnProperty.call(from, key)) { | ||
to[key] = from[key]; | ||
} | ||
} | ||
}; | ||
|
||
export default Object.assign || | ||
function(target, sources) { | ||
if (target == null) { | ||
throw new TypeError('Object.assign target cannot be null or undefined'); | ||
} | ||
|
||
const to = Object(target); | ||
|
||
for (let nextIndex = 1; nextIndex < arguments.length; nextIndex++) { | ||
const nextSource = arguments[nextIndex]; | ||
if (nextSource != null) { | ||
_assign(to, Object(nextSource)); | ||
} | ||
} | ||
|
||
return to; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters