creativetimofficial / material-dashboard

Material Dashboard - Open Source Bootstrap 5 Material Design Admin
https://www.creative-tim.com/product/material-dashboard
MIT License
11.05k stars 4.35k forks source link

[Bug] TypeError: Cannot convert object to primitive value #184

Closed mshemuni closed 1 year ago

mshemuni commented 2 years ago

Version

v2.1.0

Reproduction link

https://github.com/twbs/bootstrap/issues/30553#issuecomment-612617589

Operating System

Ubuntu

Device

PC and Mobile

Browser & Version

All Browsers

Steps to reproduce

1) Create a site using material design 2) Try to add JS9: https://js9.si.edu/ 3) add static files. refer to js9support.min.js as example shows.

What is expected?

When navbar-toggler width data-target of #navigation-example is clicked an animation to open a side bar is expected.

What is actually happening?

An error says TypeError: Cannot convert object to primitive value and no side bar is opened


Solution

https://github.com/twbs/bootstrap/issues/30553#issuecomment-612617589

chanhed this line: if (!i && l.toggle && /show|hide/.test(t) && (l.toggle = !1), i || (i = new r(this, l), o.data(n, i)), 'string' == typeof t) {

to this: if (!i && l.toggle && /show|hide/.test(l) && (l.toggle = !1), i || (i = new r(this, l), o.data(n, i)), 'string' == typeof t) {

Additional comments

Unfortunately my code is not in production. So I cannot create a codepen etc...

groovemen commented 1 year ago

Hello @mshemuni,

Thank you for using our products, the TypeError: Cannot convert the object to primitive value error typically occurs when you try to use an object in a context where a primitive value is expected, such as when you try to concatenate an object with a string using the + operator.

To fix this error, you need to convert the object to a primitive value before using it in a context where a primitive value is expected. One way to do this is by using the valueOf method, which returns the primitive value of an object.

Hope this information helps you. Please let us know if we can help you with anything else. All the best, Stefan