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

Spread transformation requires Symbol.iterator now #9277

Closed
clshortfuse opened this issue Jan 3, 2019 · 8 comments · Fixed by #9794 or #11268
Closed

Spread transformation requires Symbol.iterator now #9277

clshortfuse opened this issue Jan 3, 2019 · 8 comments · Fixed by #9794 or #11268
Labels
7.x: regression Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@clshortfuse
Copy link
Contributor

v7 Regression

Potential Commit/PR that introduced the regression

4da3f3b

Describe the regression

Transformation of Spread now requires Symbol

Input Code

const divElements = [...document.getElementsByTagName('div')];

Babel Configuration (.babelrc, package.json, cli command)

// from webpack:

module: {
  rules: [{
    test: /\.js$/,
    exclude: /(node_modules|bower_components)/,
    use: {
      loader: 'babel-loader',
      options: {
        presets: [
          ['@babel/preset-env'],
        ],
      },
    },
  }
}

Expected behavior/code

Before this commit, all you needed was a polyfill for Array.from(). Now Symbol.iterator is needed as well. This breaks IE11.

Environment

  • Babel version(s): @babel/preset-env: 7.2.3,
  • Node/npm version: 8.11.3 / 6.5.0
  • OS: OSX 10.14.2
  • Monorepo: ??
  • How you are using Babel: webpack

If, for some reason we still need Symbol.iterator, perhaps we perform the isIterable check AFTER the prototype check for [object Arguments]. That way, requiring Symbol.iterator would be a last-ditch effort.

@babel-bot
Copy link
Collaborator

Hey @clshortfuse! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo
Copy link
Member

Thank you for the bug report! We are tracking it at #7597, and there is a PR at #8947.

@clshortfuse
Copy link
Contributor Author

clshortfuse commented Jan 7, 2019

@nicolo-ribaudo I'm not sure this is the same issue, or perhaps I'm just being too specific. #7597 targets Symbol entirely, which would also remove caveats for Array destructuring and Array For Ofas listed in https://babeljs.io/docs/en/caveats . That would fall more into a "nice-to-have" category, while this is an actual regression for Spread.

This is just talking about the regression in Spread specifically. If anything, I would say PR #8947 would fix this issue as well as #7597.

@nicolo-ribaudo
Copy link
Member

I can leave this open if you prefer, just in case someone else has the same problem to avoid another issue.

@nicolo-ribaudo nicolo-ribaudo reopened this Jan 7, 2019
iezer added a commit to bustle/mobiledoc-kit that referenced this issue Jan 10, 2019
 Getting this issue: babel/babel#9277
 Which may be fixed when this PR is merged: babel/babel#8947
iezer added a commit to bustle/mobiledoc-kit that referenced this issue Jan 10, 2019
 Getting this issue: babel/babel#9277
 Which may be fixed when this PR is merged: babel/babel#8947
rondale-sc pushed a commit to rondale-sc/mobiledoc-kit that referenced this issue Jan 24, 2019
 Getting this issue: babel/babel#9277
 Which may be fixed when this PR is merged: babel/babel#8947
clshortfuse added a commit to clshortfuse/babel that referenced this issue Mar 16, 2019
clshortfuse added a commit to clshortfuse/babel that referenced this issue Mar 30, 2019
clshortfuse added a commit to clshortfuse/babel that referenced this issue Mar 30, 2019
clshortfuse added a commit to clshortfuse/babel that referenced this issue Mar 30, 2019
clshortfuse added a commit to clshortfuse/babel that referenced this issue Mar 31, 2019
@nicolo-ribaudo nicolo-ribaudo added this to Fixed issues in Iterables DX Mar 15, 2020
nicolo-ribaudo pushed a commit to clshortfuse/babel that referenced this issue Mar 15, 2020
@ljharb
Copy link
Member

ljharb commented Mar 15, 2020

That PR only solved it for strings, not yet for arrays, or Maps or Sets (all builtins should work even without the presence of Symbol.iterator)

@ljharb ljharb reopened this Mar 15, 2020
@nicolo-ribaudo
Copy link
Member

Yeah sorry, I'm opening the new PR now.

@nicolo-ribaudo
Copy link
Member

I'm leaving this open until the example in the original post works.

@nicolo-ribaudo
Copy link
Member

The original example works when using the allowArrayLike option, or the upcoming (Babel 7.13.0) arrayLikeIsIterable assumption.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
7.x: regression Has PR i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
No open projects
Iterables DX
  
Fixed issues
4 participants