Skip to content
jonathansampson edited this page Feb 8, 2013 · 2 revisions

###I'm getting SyntaxError Exceptions

jQuery's core engages in feature-detection centered around the querySelector, and matchesSelector members. In doing so it tests invalid selector syntax which raises an exception. This test is wrapped in a try...catch to prevent any interruption to the application using jQuery. While this exception isn't visible in the console output, it is visible in the debug output.

jQuery 1.8.x is on the tail-end of jQuery versions that support older browsers which don't natively support many modern features (such as querySelector and matchesSelector), and as such versions like 2.x will no longer require these tests.

Because these portions of the code are quickly becoming obsolete, we've decided to not to strip them from the 1.8 codebase even though they are irrelevant in the Windows 8 context, and serve as a merely genetic marker from when jQuery was uniquely used in web browsers.

An example from the source follows:

// This should fail with an exception
// Gecko does not error, returns false instead
try {
    matches.call( div, "div[id!='foo']" );
    rbuggyMatches.push( "!=", pseudos );
} catch ( e ) {}
Clone this wiki locally