-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use an emit helper (or Object.assign) for JsxSpreadAttributes #7952
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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null test is unnecessary
Thanks for the reactions @basarat 😄 🌹 |
@@ -345,6 +345,15 @@ var __extends = (this && this.__extends) || function (d, b) { | |||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | |||
};`; | |||
|
|||
const assignHelper = ` | |||
var __assign = (this && this.__assign) || Object.assign || function(t) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our uses this should it should be unnecessary anyway.
👍 |
92e7cb5
to
80b2a4c
Compare
80b2a4c
to
67a77dd
Compare
This PR introduces an
__assign
helper that we can leverage for React emit, as well as object spread properties down the road (with some tweaking).Fixes #7270.
@rbuckton @RyanCavanaugh @mhegazy