Chrome Developer Tools pauses the initialization of jQuery 1.7
-
28-10-2019 - |
Pergunta
Chrome's developer tools are an excellent set of tools that I love to use. Unfortunately, I've come across a very strange issue as of late when I refresh the page whilst keeping the developer tools window open: Chrome pauses the javascript execution and points to the line specified below.
try {
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call(document.documentElement, "[test!='']:sizzle"); // this is where it breaks
} catch (pseudoError) {
pseudoWorks = true;
}
An exception causes the script to pause, despite that the exception itself is positioned within a try-catch block. Is there any way I can alter this behaviour? Or is there something that I've missed?
Solução
Possibly it's a known bug , check this: http://bugs.jquery.com/ticket/7535 . I have found this solution there, I hope it helps:
try {
// This should fail with an exception
// Gecko does not error, returns false instead
// <orig. $jquery-1.5:>
// matches.call( document.documentElement, "[test!='']:sizzle" );
// <proposal to Ticket #7535, 2011-03-24:>
if( ! html.mozMatchesSelector || document.currentScript ){
matches.call( html, "[test!='']:sizzle" );
}
//else{
// /*FF lt 4*/
//}
} catch( pseudoError ) {
pseudoWorks = true;
}
// <testing only>
// alert('MalformedSelectorException thrown: ' + pseudoWorks );
Outras dicas
I've just solved this problem (in my case, might be different). I have accidentally clicked on "Pause on Exceptions" button in chrome's console. This one: https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#js_exceptions
Here's the location of that small, easy-to-miss Pause on Exceptions button, and its three toggle states:
If someone searches for
div.querySelectorAll("*,:x");
should redirect here.
If you're using Chrome, do this:
Click the Settings icon in the inspector (the cog). In General, there is a button called "Manage framework blackboxing..."
You can use this to ignore certain scripts from being evaluated in the debugger. Here's a simple regex to catch jQuery stuff. /jquery(.*)\.js$
Found this question looking for it related to Safari, so I guess the answer may be useful:
In Safari Web Inspector this can be achieved similarly by going to the Breakpoints tab (ctrl-7). Deselect "All Exceptions" and select "All Uncaught Exceptions".