Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot convert object to primitive value(zone-evergreen.js:171)

In Angular 9 (using Bootstrap 4 and Jquery 3.5.1). when clicking on bootstrap collapse button, I am getting an error on my browser console instead of a dropdown menu.

I really don't know where exactly the error came from.

Can't convert object to primitive value(zone-evergreen:171).


Uncaught Type Error: Cannot convert object to primitive value(zone-evergreen.js:171 )
    at RegExp.test (<anonymous>)
    at HTMLDivElement.<anonymous> (bootstrap.bundle.min.js:6)
    at Function.each (jquery.min.js:2)
    at S.fn.init.each (jquery.min.js:2)
    at S.fn.init.a._jQueryInterface [as collapse] (bootstrap.bundle.min.js:6)
    at HTMLDivElement.<anonymous> (bootstrap.bundle.min.js:6)
    at Function.each (jquery.min.js:2)
    at S.fn.init.each (jquery.min.js:2)
    at HTMLButtonElement.<anonymous> (bootstrap.bundle.min.js:6)
    at HTMLDocument.dispatch (jquery.min.js:2)
like image 657
Rohit Kumar Avatar asked Apr 12 '20 19:04

Rohit Kumar


2 Answers

This issue seems to be related to jQuery 3.5.0. It is a breaking change that affects many plugins. Temporarily reverting to a previous version of jQuery (like 3.4.1) fixed the issue for me.

Source: jQuery Issue #4665

Update:

jQuery 3.5.1 reverts the breaking change and should be safe to use.

Announcement: jQuery 3.5.1 Released: Fixing a Regression

like image 143
jastend Avatar answered Nov 08 '22 16:11

jastend


They have a fix for that now (see https://github.com/jquery/jquery/commit/65e909844c2d064606217b47e92eff12ebdb79de) if you are up to building your own jquery using node/npm then just download the commit on the link above and build it.

What I did was to edit my jquery.min.js (3.5.0)

Steps I did:

  1. search for the line: return t||(t=Object.create(null) it's in Line 2,Column 32856
  2. replace Object.create(null) with {}

and that's it so far so good

like image 37
Sybregunne Avatar answered Nov 08 '22 16:11

Sybregunne