theseus
theseus copied to clipboard
Theseus and Jquery Throwing Errors on Live Preview
Sprint 34 experimental build 0.34.1-10733 Using bower installed jquery version 2.0.3.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="scripts/bower_components/jquery/jquery.js"></script>
</head>
<body>
</body>
</html>
SyntaxError: Failed to execute query: '*,:x' is not a valid selector. (line 1482) SyntaxError: Failed to execute query: '[s!='']:x' is not a valid selector. (line 1514)
It is happening in the assert functions in jquery that checks for browser support.
Do you know if the jQuery is minified?
When I try it with jQuery off the jQuery site, I get no exceptions just from loading jQuery, but I get 2 exceptions with minified jQuery:
[Error] TypeError: 'undefined' is not a function (near '...4-6267", vars: {} })(t))...') (j2.js, line 1650)
[Error] TypeError: 'undefined' is not a function (near '...4-2917", vars: {} })(o,[x]),x.fn.trigger...') (j2.js, line 1596)
Let's see where these are coming from...
It is not the minified version. Note that everything seems to run fine with theseus turned off. These errors arent getting thrown.
I downloaded the latest unmin'd version of jquery from their site at http://code.jquery.com/jquery-2.0.3.js and I'm still getting those errors.
That's weird. I'll see how closely I can recreate your setup.
Note that the extension downloaded by brackets is v.0.4.8 - 2013-09-03
Was there any insight into this? I am also seeing this, though not with theseus, but other jquery plugins.
No, not yet, sorry. I think there was another report about jQuery 2 being broken but I haven't found the time to look into either yet.
It can be worked around by requesting jquery.js?theseus=no
for the time being.
No worries, thanks for the quick response!
Same problem here with the very last theseus version (0.4.13), very last bracket version (41) and very last unminified jquery version (2.1.1)..
Do you have new insights about this issue and where it comes from?
I cannot use the theseus=no trick
as I'm using requirejs... :-/
Sorry. :\
If the problem is what I think it is, when fondue inserts the instrumentation code for Theseus, it unintentionally makes the JavaScript invalid. Before the initial release of Theseus, I spent several days just getting minified jQuery to work because it uses every trick it can to make the file as small as possible. It seems like they found a new trick for jQuery 2 that I haven't figured out.
If I'm correct, unminified jQuery ought to work, and inserting /*theseus instrument: false */
into jQuery somewhere ought to work.
I'm bumping this to the top of my todo list to look at today. :)
You all are getting the errors in Chrome, right?
All right, I can finally reproduce this!
It turns out that the exceptions are benign, if annoying. :)
jQuery's assert()
returns false if the assertion throws an exception. However, Theseus logs all exceptions that cause a function to abort, even if they're caught somewhere else (such as in assert()
). So even though the exceptions are part of the normal browser detection control flow, they show up in Theseus's events bar.
There are a couple of things that should be done:
- [ ] Display caught exceptions differently from uncaught exceptions.
- [ ] Show where caught exceptions were caught.
If you don't care what happens in jQuery, I recommend disabling Theseus for that file using one of the methods mentioned earlier (which also described here).
If an exception is caught, the stack will show where:
If an exception is not caught, you can now see it propagate all the way up the stack:
The log now only shows uncaught exceptions. However, the exception counter is now wrong because it's counting the number of invocations that exited with an exception instead of the number of times an exception made it all the way up the stack:
With that commit to Theseus, I think this issue is resolved. Could someone (preferably everyone :) try this test build of Theseus?