2

I have a problem with Material Design Bootstrap, I added it with NPM but when I'm on my website, I got this error :

Uncaught TypeError: Cannot read property 'hasAttribute' of null
    at r (app.js:19116)
    at Module.o.m.n (app.js:19116)
    at o (app.js:19116)
    at app.js:19116
    at app.js:19116
    at Object../node_modules/mdb-ui-kit/js/mdb.min.js (app.js:19116)
    at __webpack_require__ (app.js:19361)
    at Object../resources/js/app.js (app.js:1845)
    at __webpack_require__ (app.js:19361)
    at app.js:19500

And there is where is the problem: hasAttribute("data-mdb-no-jquery"). I don't know how I can correct this problem.

Thank you for your answers !

lmcanavals
  • 2,339
  • 1
  • 24
  • 35
Miyonu
  • 35
  • 1
  • 7

1 Answers1

1

Can you send the code block where you are using this line?

Cannot read property 'hasAttribute' of null means that somewhere you are doing something like myVariable.hasAttribute(...) but the value of myVariable is null or undefined so there is no function to call.

Adi
  • 41
  • 3
  • Yes, I had a piece of code that was not recognized by mdb, probably due to the switch from bootstrap 4 to 5? I had tried little by little to remove some code and after a while it worked! – Miyonu May 20 '21 at 16:37
  • 2
    @ThomasOrgeval how did you make it work? I am facing the same problem – Ankit Sahay Jan 30 '22 at 07:33
  • @AnkitSahay sorry I don't really remember, but I had deleted some of the MDB code, or I had done an installation with CDNs I think – Miyonu Feb 11 '22 at 11:10
  • 1
    I am currently facing the same issue here. I am debugging the same line where the error appears, but whenever I execute that same line `(jQuery && !document.body.hasAttribute('data-mdb-no-jquery'))` I get `true` – Oris Sin Aug 18 '22 at 12:19