Open fskreuz opened 6 years ago
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.
array.concat
Input:
const foo = [...someElement.childNodes] // Expected [node, node, node, ...]
Output:
var foo = [].concat(someElement.childNodes) // Actual [NodeList{}]
We discussed some solutions in #81. Destructuring and for-of loops have closely related issues.
Spreading a NodeList into an array works in vanilla JS. The following example will log an array containing text, p, text, p, text.
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:
Output: