debugbar icon indicating copy to clipboard operation
debugbar copied to clipboard

Breaks jQuery for versions >=0.3.2

Open fynsta opened this issue 1 year ago • 11 comments

We use jQuery via the jquery-rails gem. Upgrading the debugbar to 0.3.2 just completely breaks the jQuery installation (via the debugbar_head helper where it loads the script).

With this issue:

$.fn // => undefined

And after commenting out = debugbar_head if Rails.env.development?

$.fn // => {jquery: '3.7.0', length: 0, toArray: ƒ, get: ƒ, pushStack: ƒ, …}

This happens no matter which file is required first.

fynsta avatar Jun 20 '24 13:06 fynsta

I'm looking at the diff and I don't get how 0.3.1 could work but the later versions 🤔 https://github.com/julienbourdeau/debugbar/compare/63d99c68bcd935f7b45cbba8abcac91301c2e223...6df7e2ebfda55b529f59e22e36bafdfc9adbc945

I'm assuming you don't get any error in the console and you ran assets:precompile.

julienbourdeau avatar Jul 12 '24 15:07 julienbourdeau

Yes. I was looking through the same diff and could not figure it out. The same behaviour has been observed by other members of the team when switching back-and-forth between versions of this gem.

fynsta avatar Jul 17 '24 20:07 fynsta

I'm seeing this too when running on top of Solidus, which has jquery baked in for the /admin site...

@fynsta any tips if you were able to find a work around?

@julienbourdeau such a cool looking tool! awesome!

erwin avatar Jul 23 '24 14:07 erwin

@erwin No sorry, we just rolled back to 0.3.1. and are running that one for now.

fynsta avatar Jul 23 '24 21:07 fynsta

I had luck doing this:

var $j = jQuery.noConflict();

And then using $j instead of $ everywhere... Not an ideal fix...

Here is the commit that demonstrates this workaround: https://github.com/o19s/quepid/commit/d1a002f7c2af425403a29545834cc801114732c9#diff-8fa62161b01787efd56863c19b7e712a949073dc606415d6d8cfe319ecc689ecR61

epugh avatar Jan 07 '25 12:01 epugh

I'll try to setup o19s/quepid to see if I figure out the jquery issue

julienbourdeau avatar Jan 07 '25 14:01 julienbourdeau

To run quepid, check out the source and it assumes you have ruby installed locally (3.3.6). it runs in docker, so ..

bin/setup_docker
bin/docker server

Go to http://localhost:3000

Log in as [email protected] and password password.

Go to the Judgement interface: http://localhost:3000/books/1/judge and click the buttons.

To make the code work, you need to revert the change that I made to work around thigns!

Let me know and I am happy to pair.

epugh avatar Jan 07 '25 15:01 epugh

i also think I need to work towards getting rid of rails-jquery, but I am half on sprockets and half on importmaps, and can't quite figure out how to get to propshaft and get rid of sprockets.

epugh avatar Jan 07 '25 15:01 epugh

I think on the latest 0.4.3 of debug var this issue has been resolved! Just tested it with Quepid.

epugh avatar Feb 05 '25 19:02 epugh

Excellent news! No idea why or how tho 😳

julienbourdeau avatar Feb 06 '25 08:02 julienbourdeau

Sadly I don't work at my previous workplace anymore, so I cannot check this on our side. But if it's confirmed, we can close this issue of course!

fynsta avatar Feb 10 '25 12:02 fynsta