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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰Fix IE11 with a basic polyfill #18941

Merged
merged 2 commits into from Oct 25, 2018
Merged

Conversation

cvializ
Copy link
Contributor

@cvializ cvializ commented Oct 24, 2018

Fixes #18184 with a partial polyfill instead of the full polyfill from #18879

The partial polyfill is OK because the Array.from call in _toConsumableArray (generated from the spread operator usages) is only ever called with Arrays or false:

https://github.com/airbnb/react-dates/blob/f48b820449b2a460761ead4c056ccfac2322bb78/src/components/DayPickerNavigation.jsx#L109-L123

return [];
}

return [].concat(arrayLike);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to do a for loop? Concat will only spread arrays, not array-likes.

// A very basic polyfill for Array.from,
// to avoid needing to use a full 3p implementation
if (!Array.from) {
Array.from = function (arrayLike) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.defineProperty(Array, 'from', {
  writable: true,
  enumerable: false,
  configurable: true,
  value: poly,
});

@cvializ
Copy link
Contributor Author

cvializ commented Oct 25, 2018

@jridgewell PTAL

@cvializ cvializ merged commit 55af1fe into ampproject:master Oct 25, 2018
@cvializ
Copy link
Contributor Author

cvializ commented Oct 25, 2018

Thank you for your review!

Enriqe pushed a commit to Enriqe/amphtml that referenced this pull request Nov 28, 2018
* Fix IE11 with a basic polyfill

* review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants