Use an emit helper (or Object.assign) for JsxSpreadAttributes#7952
Merged
Conversation
| var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
| for (var i = 1, n = arguments.length; i < n; i++) { | ||
| var s = arguments[i]; | ||
| if (s != null) for (var p in s) if (s.hasOwnProperty(p)) t[p] = s[p]; |
Contributor
There was a problem hiding this comment.
The null test is unnecessary
Member
Author
|
Thanks for the reactions @basarat 😄 🌹 |
| };`; | ||
|
|
||
| const assignHelper = ` | ||
| var __assign = (this && this.__assign) || Object.assign || function(t) { |
There was a problem hiding this comment.
Polyfill I found (and what React used) convert t into an object, like:
if (t == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
var result = Object(t);
I'm unsure if this is necessary with current browsers. But https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill does to.
Member
Author
There was a problem hiding this comment.
For our uses this should it should be unnecessary anyway.
Member
|
👍 |
92e7cb5 to
80b2a4c
Compare
80b2a4c to
67a77dd
Compare
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces an
__assignhelper that we can leverage for React emit, as well as object spread properties down the road (with some tweaking).Fixes #7270.
@rbuckton @RyanCavanaugh @mhegazy