csnover / TraceKit

Attempts to create stack traces for unhandled JavaScript exceptions in all major browsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jQuery detection detectng more than jQuery

aim12340 opened this issue · comments

The jQuery detection here:
if (!$) {
return;
}

detects any $ function as jQuery, which is often not the case. When another $ function exists it passes this test and i then get various other errors below this line.

a good alternative seems to be
if (typeof jQuery == 'undefined') {
return;
}

hope you can include this is the next update

You are reading that code out-of-context. It is valid and correct.

can you explain what i'm missing here?

whatever the context, (!$) still lets non-jQuery objects/functions though to code that will cause an error.

unless you mean that TraceKit just isn't supposed to be used except in tightly controlled system where you know (!$) can only be jQuery?

Congrats on an awesomely useful tool BTW.

It is inside an IIFE that defines $ in the local scope to window.jQuery. See lines 1002 and 1117.

OK, I see what you mean now. Yes, (typeof jQuery == 'undefined') should be the same as (!$).

I was getting different errors with the 2 different IFs, but now i'll put that down to differences in my visitors, not in the function as it seems the IFs will give the same result.

I'm still getiing errors in the $ and W functions though. I'll start another bug report if i can come up with some useful info.