Side navigation
#110 closed bug (fixed)
Opened July 28, 2006 04:33PM UTC
Closed August 15, 2006 04:40AM UTC
Last modified June 20, 2007 01:19AM UTC
Multiple Attribute Selectors Broken
Reported by: | john | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.0 |
Component: | core | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I was having trouble with the form plugin and while debugging I
discovered that quotes are necessary when selecting by attribute
values * if * the selection contains more than one item.
The following test page shows this more clearly:
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN"
"http:www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript" src="jquery-v164.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert("with quotes: "
+$("input[@type='hidden'],input[@type='text']").size());
alert("w/o quotes: "
+$("input[@type=hidden],input[@type=text]").size());
});
</script>
</head><body><div>
<form><div>
<input type="text" name="t" />
<input type="hidden" name="h" />
</div></form>
</div></body></html>
The first alert shows 2, the second alert shows 0. However the
following lines will both correctly alert 1:
alert("with quotes: " +$("input[@type='hidden']").size());
alert("w/o quotes: " +$("input[@type=hidden]").size());
So there is either a bug in the selection logic (if quotes are not
meant to be required) or in the form plugin which does this:
$("input[@type=submit],input[@type=image]", this)
This W3C page says "Attribute values must be identifiers or strings" so it
seems the quotes should be optional for simple names.
http://www.w3.org/TR/css3-selectors/#attribute-selectors
It looks like the problem is here in .filter():
// Look for something (optionally) enclosed with quotes
.replace( 'Q', " *'?"?([^'"]*)'?"? *" ), "i" );
I think the [^'"]* part of the regexp is eating up too much of the selector
string.
Attachments (0)
Change History (1)
Changed August 15, 2006 04:40AM UTC by comment:1
resolution: | → fixed |
---|---|
status: | new → closed |
Resolved in SVN rev 206.