Skip to content
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

Merged
merged 6 commits into from
Apr 8, 2016

Conversation

DanielRosenwasser
Copy link
Member

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

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];
Copy link
Member

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

@DanielRosenwasser
Copy link
Member Author

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) {
Copy link

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.

Copy link
Member Author

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.

@RyanCavanaugh
Copy link
Member

👍 && thank you @gaearon

@DanielRosenwasser DanielRosenwasser merged commit a7bf690 into master Apr 8, 2016
@DanielRosenwasser DanielRosenwasser deleted the objectAssignPoly branch April 8, 2016 20:24
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants