Skip to content

Tabs bug fix (attrib selector quotes)#596

Closed
bbodien wants to merge 5 commits intojquerytools:masterfrom
neutroncreations:master
Closed

Tabs bug fix (attrib selector quotes)#596
bbodien wants to merge 5 commits intojquerytools:masterfrom
neutroncreations:master

Conversation

@bbodien
Copy link

@bbodien bbodien commented Dec 15, 2011

jQuery 1.5+ requires attribute selector values in selectors to be wrapped in quotes, for example:

$("a[href='#location']")

instead of:

$("a[href=#location]")

My latest commit here adds single quotes around an attribute value in jQuery Tools Tabs, which was causing uncaught jQuery exceptions.

The other commits in this request pertain to an earlier pull request: #533 but I'm not sure how to only include a specific commit for this request.

@duclet
Copy link

duclet commented Jan 4, 2012

The next version will be using jQuery 1.7.1 or later as the base and I don't see an issue with the selector if there isn't a quote around them. I can't seem to find it in the jQuery docs either to where it says this is a requirement. Can you perhaps point me to where it says that?

I've added the following fiddle to test this in the various browser, Chrome, FF, IE7-9, and it all works fine.
http://jsfiddle.net/duclet/Cf9hs/

@bbodien
Copy link
Author

bbodien commented Jan 4, 2012

The error arose when using a history push plugin, resulting in an attribute selector for an href value that contained an equals sign:

[href='#onlyremote=1']

In this scenario (which I admit is an edge case since you can't have equals signs in element ids, so this could only arise from this kind of history push usage), the quotes around the attribute value are required to avoid ambiguity with the equals signs.

In any case, the jQuery docs themselves specify that quotes are mandatory: http://b.ntrn.cc/1X3E0F3h0S3F3v3w3c0W (from http://api.jquery.com/attribute-equals-selector/).

See also: http://api.jquery.com/category/selectors/attribute-selectors/ which states:

Attribute values in selector expressions must be surrounded by quotation marks.

@duclet
Copy link

duclet commented Jan 4, 2012

Thanks for the info. I was looking thru the change logs but should have just looked at the documentation :)

I think it is safe to get this pull request then but only for the selected file. We should also probably have another ticket to go thru the code and add in quotes for all places where it is missing.

@duclet
Copy link

duclet commented Jan 19, 2012

Please make this pull request to dev branch instead.

@jbasdf
Copy link

jbasdf commented Jan 27, 2012

I can confirm the need for attribute selectors due to a recent change in the Facebook API. If you are using Facebook to login you will be redirected to a url like this:
http://localhost:3000/users/2#_=_

If tabs are enabled on the pages upon which the user lands this error occurs:
Error: Syntax error, unrecognized expression: [href=#=]

I can confirm that commit 3f29890 fixes the error.

Here's a link to the Facebook issue for reference:
https://developers.facebook.com/blog/post/552/

@phelios
Copy link

phelios commented Feb 23, 2012

Another example on this getting stuck is when using ajax with history together. When the link address has special character (/ or ? which are common on URLs), there will be errors.

I think I will just manually update my local version then.

@duclet
Copy link

duclet commented Feb 27, 2012

Done inf #679. Though I see you have a feature added here. Please create another pull request just for it if you still want it part of the library. Please follow the guidelines in the wiki. Thanks for helping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants