Skip to main content

Bug Tracker

Side navigation

#4394 closed bug (invalid)

Opened March 20, 2009 07:56PM UTC

Closed October 27, 2010 11:03PM UTC

Last modified October 27, 2010 11:17PM UTC

Jquery 1.3.2 (Sizzle) cannot use attribute selectors with an odd number of apostrophes in the values.

Reported by: benjamin.keil@finant Owned by: john
Priority: major Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: quotes Cc: benjamin.keil@finantix.com
Blocked by: Blocking:
Description

Given some elements with apostrophe's in their attribute values:

$("body").append("<span title='James's'>Here</span>");

$("body").append("<span title='St. James's Places'>There</span>");

I expect $("[title=\\"James's\\"]").text() to be "Here" and $("[title=\\"St. James's Place\\"]).text() to be "There".

In the first case what I get (with various attempts at escaping the apostrophe) is:

|| $("[title=\\"James's\\"]").text() || Syntax error, unrecognized expression: title="James's"] ||

|| $("[title=\\"James's\\"]").text(); || "" ||

|| $("[title=James's]").text(); || Syntax error, unrecognized expression: title=James's] ||

|| $("[title=James\\'s]").text(); || Syntax error, unrecognized expression: title=James's] ||

|| $("[title=James\\\\'s]").text(); || Syntax error, unrecognized expression: title=James\\'s] ||

Trying for the second one, I get slightly different exceptions:

|| $("[title=\\"St. James's Place\\"]").text(); ||Syntax error, unrecognized expression: Place"] ||

|| $("[title=\\"St. James's Place\\"]").text(); || "" ||

|| $("[title=St. James's Place]").text(); || Syntax error, unrecognized expression: Place] ||

|| $("[title=St. James\\'s Place]").text(); || Syntax error, unrecognized expression: Place] ||

|| $("[title=St. James\\\\'s Place]").text(); || Syntax error, unrecognized expression: Place] ||

If, however, I use an even number of apostrophes, then all is well:

$("body").append("<span title='St. James's' Place'>Yonder</span>");

|| $("[title=St. James's' Place]").text(); || "Yonder" ||

|| $("[title=\\"St. James's' Place\\"]").text(); || "Yonder" ||

|| $("[title=St. James\\'s\\' Place]").text(); || "Yonder" ||

|| $("[title='St. James\\'s\\' Place']").text(); || "Yonder" ||

Even $("[title='St. James's' Place']").text() results in "Yonder", which I find surprising.

Attachments (0)
Change History (3)

Changed March 21, 2009 01:19AM UTC by dmethvin comment:1

component: unfilledselector
keywords: → quotes
owner: → john

Changed October 27, 2010 11:03PM UTC by rwaldron comment:2

resolution: → invalid
status: newclosed

The best part is that the value of the second span'a title attr is "St. James's Places"... but you actually test for "St. James's Place" - you're missing an "s".

Please be more careful in the future

http://jsfiddle.net/rwaldron/uZhFj/1/

Changed October 27, 2010 11:17PM UTC by rwaldron comment:3

ALSO... There is a typo here as well:

'''$("[title=\\"St. James's Place\\"]).text()'''