unrecognized expression: #
I’ve tried to use one of my own jQuery plugins—that I know works—only to receive the following console messages without any reference to a code line number, hence no way to track down the culprit:
uncaught exception: Syntax error, unrecognized expression: #
I’m sure this has caught me out a number of times. Each time is far enough apart that I have forgotten how I debugged the issue previously. And each time I search the interwebs in vain. No one seems to have clearly explained what causes this exception!
Next time I encounter this problem, hopefully I remember—or find—this post, solution follows…
This exception is thrown by jQuery when you ask it to resolve the selector
'#' without an
id following. In my case it is often caused by my plugin code assuming an element has an
id. If the element doesn’t have an
id, the exception is thrown, for example:
var storedID = $(this).attr('id');
this doesn’t have an
id, I’ve essentially asked jQuery to resolve the following:
Which jQuery doesn’t like to do, hence the exception.
Finally got around to fixing my corrupt zip file issues. Fresh and flawless zip files are now available for the latest versions of all widgets and plugins.
BTW the compact content plugins have been updated with a bunch of small fixes (IE6 benefits the most from this release). See new examples, downloads and changelog for version 3.5.
Test support for short URL auto-discovery
Short URL autodiscovery sounds like a good idea to me. The easiest way for a developer to integrate this mechanism is to use the link element in your document’s
<link rel="shorturl" href="http://irama.org/673" />
Or if you are using WordPress there are few handy plugins that do this automatically (for example: Short link maker and Shorter links).
But who’s going to know you’ve gone to all this trouble? How far has support for auto-discovery penetrated? I think it would be great if social media client applications would offer my short URL to users when they choose to shorten URLs within their posts, but I can’t find much documentation about which if any apps will pick up and use short URLs exposed in this way.
Go forth and test
This post can serve as a test, and a collection point for data, leave a comment if you have tested a new client application (include the version if known), and I’ll do the same.
ARIA keyboard navigation best practice
I finished updating the ARIA keyboard navigation plugin tonight.
As of this version the plugin manages focus using tabindex alone, which means it functions in browsers old and new (whether they support ARIA explicitly or not). Browser support has been tested with Firefox 3.6.3, Chrome 4, Safari 4, Opera 10.51 and the Trident Trio (IE 6, 7 and 8).
During the refactoring I also managed to shave ~170 lines from total code weight — and this version has more comments!
In light of increasing browser support for CSS3 media queries, I have spent some time today updating the transformer layout plugin in an attempt to achieve a seamless integration of the new CSS3 functionality for including stylesheets dependent on the browser’s current viewport width.
Most media query implementations I have seen use
px units to define
max-width limits. This approach is fine for browsers that zoom, but less than ideal for browsers that don’t. Not a huge issue when you consider that the modern browsers that support media queries all zoom by default! But for transformer layout to retain support for older browsers that don’t zoom,
em units would be the way to go.
Firstly, I ran some tests of current browser support for CSS3 media queries using
em units, the results were:
- Firefox (3.6.2) and Opera (10) support media queries with
em units and load the correct stylesheet after zoom level change.
- Chrome (4) and Safari (4) support media queries with
em units but fail to load the correct stylesheet after zoom level change.
- IE (6, 7 and 8 ) do not support media queries at all.
Alexander Farkas has a nice solution for detecting media query support and supplementing for non-supporting browsers but unfortunately it doesn’t support
em units or compensate for Safari and Chrome’s insufficient handling of zoom level changes.
The new transformer layout plugin takes Alexander’s great work and rectifies both of those limitations so now it can be used to achieve an approach to layout optimised for all browsers, devices, resolutions, text sizes and zoom levels.