theseus icon indicating copy to clipboard operation
theseus copied to clipboard

Theseus and Jquery Throwing Errors on Live Preview

Open pixelshaded opened this issue 11 years ago • 16 comments

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.

pixelshaded avatar Dec 09 '13 17:12 pixelshaded

Do you know if the jQuery is minified?

alltom avatar Dec 09 '13 22:12 alltom

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...

alltom avatar Dec 09 '13 22:12 alltom

It is not the minified version. Note that everything seems to run fine with theseus turned off. These errors arent getting thrown.

pixelshaded avatar Dec 09 '13 23:12 pixelshaded

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.

pixelshaded avatar Dec 09 '13 23:12 pixelshaded

That's weird. I'll see how closely I can recreate your setup.

alltom avatar Dec 09 '13 23:12 alltom

Note that the extension downloaded by brackets is v.0.4.8 - 2013-09-03

pixelshaded avatar Dec 09 '13 23:12 pixelshaded

Was there any insight into this? I am also seeing this, though not with theseus, but other jquery plugins.

cthrax avatar Jan 23 '14 21:01 cthrax

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.

alltom avatar Jan 23 '14 21:01 alltom

No worries, thanks for the quick response!

cthrax avatar Jan 23 '14 21:01 cthrax

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... :-/

QuentinRoy avatar Jul 31 '14 10:07 QuentinRoy

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. :)

alltom avatar Jul 31 '14 18:07 alltom

You all are getting the errors in Chrome, right?

alltom avatar Aug 02 '14 02:08 alltom

All right, I can finally reproduce this!

alltom avatar Aug 02 '14 02:08 alltom

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).

alltom avatar Aug 02 '14 03:08 alltom

If an exception is caught, the stack will show where:

screen shot 2014-08-02 at 3 18 14 pm

If an exception is not caught, you can now see it propagate all the way up the stack:

screen shot 2014-08-02 at 3 18 58 pm

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:

screen shot 2014-08-02 at 3 19 13 pm

alltom avatar Aug 02 '14 22:08 alltom

With that commit to Theseus, I think this issue is resolved. Could someone (preferably everyone :) try this test build of Theseus?

alltom avatar Aug 02 '14 22:08 alltom