Micromodal icon indicating copy to clipboard operation
Micromodal copied to clipboard

Invalid attempt to spread non-iterable instance

Open t3db0t opened this issue 4 years ago • 6 comments

Hi there! I just came back to a project from about a year ago and I'm now getting this error on a previously working codebase that I hadn't made any changes to:

jquery.min.js:2 jQuery.Deferred exception: Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method. TypeError: Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
    at https://unpkg.com/[email protected]/dist/micromodal.min.js:1:847
    at t (https://unpkg.com/[email protected]/dist/micromodal.min.js:1:997)
    at Object.init (https://unpkg.com/[email protected]/dist/micromodal.min.js:1:6393)
    at HTMLDocument.<anonymous> (http://127.0.0.1:8887/lib/index.js:77:16)
    at j (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js:2:29588)
    at k (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js:2:29902)

This is in Chrome 80.0.3987.162. When I comment out any use of micromodal everything works again.

t3db0t avatar Apr 30 '20 20:04 t3db0t

I have the same problem. I think is due to Micromodal switching to babel7 while having an error in code that was silently accepted by Babel 6 https://github.com/babel/babel/issues/9942#issuecomment-489389297 This pull request https://github.com/ghosh/Micromodal/pull/313 should resolve it

Kilbourne avatar Jun 03 '20 10:06 Kilbourne

I'm having the same issue in a codebase still using Babel 6 - even if I try to run micrmodal through Babel at build time for my app, I still have the issue. I've also attempted using the polyfills suggested in #49 - I'm not using WebPack so the other recommendations don't work.

I have no idea how to fix this issue myself, but if #313 will fix it, I hope this can be merged soon.

joshvickerson avatar Jun 22 '20 21:06 joshvickerson

I was able to fix this for my own use - see my comment in #315

joshvickerson avatar Jun 24 '20 16:06 joshvickerson

I'm also seeing this in chrome

bennlich avatar Jan 20 '21 21:01 bennlich

It appears to happen when the Array prototype gets messed with before calling micromodal.init(), which jquery seems to do on import.

E.g. to reproduce:

Array.prototype.randomElement = function () {
  console.log('hello')
}
		
MicroModal.init()

bennlich avatar Jan 20 '21 21:01 bennlich

Anyone have an idea on a fix for this at all please? Having to pull in jQuery for some 3rd party code and it's breaking my code...

tomgreenhill avatar Jul 26 '21 10:07 tomgreenhill