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

Buble's spread will not work on array-like (i. e. iterable) objects #131

Open
fskreuz opened this issue May 8, 2018 · 1 comment
Open
Labels

Comments

@fskreuz
Copy link
Contributor

fskreuz commented May 8, 2018

Spreading a NodeList into an array works in vanilla JS. The following example will log an array containing text, p, text, p, text.

<div>
  <p>Hello, World!</p>
  <p>Lorem Ipsum</p>
</div>
console.log([...document.querySelector('div').childNodes])

However, because Buble uses array.concat for spread, it will fail on array-like objects because concat will only "spread" arrays. Anything else, it just appends to the target array as is.

Input:

const foo = [...someElement.childNodes] // Expected [node, node, node, ...]

Output:

var foo = [].concat(someElement.childNodes) // Actual [NodeList{}]
@adrianheine adrianheine pinned this issue Mar 2, 2019
@adrianheine adrianheine changed the title Buble's spread will not work on array-like objects Buble's spread will not work on array-like (i. e. iterable) objects Mar 2, 2019
@adrianheine
Copy link
Member

We discussed some solutions in #81. Destructuring and for-of loops have closely related issues.

ewen-lbh added a commit to ewen-lbh/umami that referenced this issue Dec 17, 2023
ewen-lbh added a commit to ewen-lbh/umami that referenced this issue Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants