materialize icon indicating copy to clipboard operation
materialize copied to clipboard

Cannot use 'in' operator to search for 'Array'

Open wobsoriano opened this issue 4 years ago • 2 comments

Hi. I've added materializecss to my vite project and getting this error when building my app

materialize.min.js:6 Uncaught TypeError: Cannot use 'in' operator to search for 'Array' in undefined
    at Object.$jscomp.polyfill (materialize.min.js:6)
    at materialize.min.js:6

The error is something in the anime library.

Here's the deployed app with the error https://vitecoil.now.sh/ and here's a sample repo https://github.com/sorxrob/vite-coil-simulator

Any help would be much appreciated.

wobsoriano avatar May 10 '20 12:05 wobsoriano

I've had the same issue when importing the .min.js file directly. It works when importing it as a dependency, but that doesn't allow me to change parts of the code. Have you found a solution for this yet, @wobsoriano?

daan33 avatar Oct 26 '21 16:10 daan33

I've had the same issue when importing the .min.js file directly. It works when importing it as a dependency, but that doesn't allow me to change parts of the code. Have you found a solution for this yet, @wobsoriano?

Have no idea now. I don't remember 😆

Just waiting for vuetify 3

wobsoriano avatar Oct 26 '21 16:10 wobsoriano

I have the same problem with en vue3 using vite, someone has some solution

juanvictorbascopecastro avatar Sep 21 '22 14:09 juanvictorbascopecastro

@juanvictorbascopecastro skip this one and use primevue with material theme

wobsoriano avatar Sep 21 '22 14:09 wobsoriano

manage to solve the problem for materialize.js in line 1509 in vercion 1.0.0-rc.2 replace the following code p = $jscomp.global;e = e.split(".");for (m = 0; m < e.length - 1; m++) { with let p = $jscomp.global;e = e.split("."); if(!p) p = new Array();for (m = 0; m < e.length - 1; m++) {

let p = $jscomp.global;e = e.split("."); if(!p) p = new Array();for (m = 0; m < e.length - 1; m++) { var u = e[m];u in p || (p[u] = {});p = p[u]; }e = e[e.length - 1];m = p[e];r = r(m);r != m && null != r && $jscomp.defineProperty(p, e, { configurable: !0, writable: !0, value: r });

juanvictorbascopecastro avatar Sep 21 '22 15:09 juanvictorbascopecastro

I could not figure out how to apply the solution provided here so instead of modifying the materialize.js file in the Gems I created my own under a custom directory. I applied the change to the materialize.js file in my new dir and then applied the steps found here: https://stackoverflow.com/a/71303435/788322

I'm on a new Rails 7 app.

ChidoYo avatar Aug 15 '23 17:08 ChidoYo

@ChidoYo Last update is 2020. I don't think it's wise to use this

wobsoriano avatar Aug 15 '23 18:08 wobsoriano

@wobsoriano It's working for me and it cleared any errors on my console.
I used the solutions offered by @juanvictorbascopecastro on Sept 2022. This is just an App I'm playing with so I'm ok continuing on. If you have a better approach on this please provide it. I'm open to suggestions.

ChidoYo avatar Aug 15 '23 18:08 ChidoYo