Bug Tracker

Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#7216 closed bug (fixed)

[Regression] $('input[value=]').live('change', ...) does not work in 1.4.3 (FF 3.6.10)

Reported by: Glen.84 Owned by: john
Priority: blocker Milestone: 1.5
Component: selector Version: 1.4.4
Keywords: regression Cc:
Blocked by: Blocking:

Description

http://jsfiddle.net/9QjJD/4/

Same with $('input[value!=]').

Change History (29)

comment:1 Changed 10 years ago by seankoole

comment:2 Changed 10 years ago by snover

Component: unfiledevent
Priority: undecidedblocker
Status: newopen

comment:3 Changed 10 years ago by Rick Waldron

comment:4 Changed 10 years ago by snover

Resolution: duplicate
Status: openclosed

comment:5 Changed 10 years ago by snover

Duplicate of #7243.

comment:6 Changed 10 years ago by Glen.84

Isn't #7243 a duplicate of this bug, since it was created after it?

comment:7 Changed 10 years ago by Glen.84

comment:8 Changed 10 years ago by john

Isn't that an invalid selector? You can't do !=] or =] - you have to have quotes. Changing that makes it work: http://jsfiddle.net/geX3c/2/

comment:9 Changed 10 years ago by Glen.84

As mentioned on IRC, it worked in 1.4.2 and the documentation says the quotes are optional.

The documentation should be updated if the selector is invalid.

Thanks.

comment:10 Changed 10 years ago by john

I've updated all the selector docs to represent this: http://api.jquery.com/category/selectors/attribute-selectors/

comment:11 Changed 10 years ago by Glen.84

"Attribute values in selector expressions can be written as bare words and must be surrounded by quotation marks."

Shouldn't that be *cannot* be written as bare words? Or simply ...

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

comment:12 Changed 10 years ago by cowboy

The docs are now somewhat confusing, as they suggest doing something syntactically impossible: jQuery('[attribute|='value']').

http://gyazo.com/d29d38d82859a4c574cb96fe19cd9ff6.png

All the attribute selector "name" values should combine single/double quotes and be formatted as either jQuery("[attribute|='value']") or jQuery('[attribute|="value"]'), whichever is more universally consistent.

Last edited 10 years ago by cowboy (previous) (diff)

comment:13 Changed 10 years ago by anonymous

@cowboy (comment:12) I've changed the syntax errors in all attribute pages to match

jQuery('[attribute|="value"]')

comment:14 in reply to:  13 Changed 10 years ago by seankoole

Replying to anonymous:

@cowboy (comment:12) I've changed the syntax errors in all attribute pages to match

jQuery('[attribute|="value"]')

Wasn't logged in, but that was me :)

comment:15 Changed 10 years ago by kswedberg

Component: eventselector
Resolution: duplicate
Status: closedreopened

Changing the docs isn't a sufficient fix for this problem, especially for a 1.x.x release, since it potentially breaks a lot of existing code. Additionally, examples in the CSS spec suggest that quotes are optional: http://www.w3.org/TR/CSS2/selector.html#attribute-selectors

This bug was closed as duplicate of #7243, but they're really two separate issues.

comment:16 Changed 10 years ago by snover

Keywords: regression needsreview added

Quotes are optional only if the value part is an ident. This is detailed in the css3 grammar.

comment:17 Changed 10 years ago by john

Owner: set to john
Status: reopenedassigned

Ok, Karl provided another test case: http://jsfiddle.net/XEAuc/1/

This is more than when there's no content on the right hand side. I'll look into this.

comment:18 Changed 10 years ago by john

Think this might fix it, will try later:

.replace(/=\s*([^'"\]]*)\s*\]/g, "='$1'")
Last edited 10 years ago by john (previous) (diff)

comment:19 Changed 10 years ago by John Resig

Resolution: fixed
Status: assignedclosed

Ensure that unquoted attribute selectors are quoted (allowing them to go into qSA/matchesSelector properly). Fixes #7216.

Changeset: b0e1e83aa987279dcdb81112ec942c161111be17

comment:20 Changed 10 years ago by ajpiano

Keywords: needsreview removed

comment:21 Changed 10 years ago by webmaster@…

This "bug fix" doesn't seem to work correctly in all cases. Refer to the example on the Selectors page of the Documentation for a simple example that doesn't work with jQuery 1.4.4.

http://api.jquery.com/category/selectors/ (example in second paragraph... try to run this code in jQuery 1.4.4)

It seems that the modification made by this bug fix in the Sizzle function seems to choke on some of the meta-characters that are supposed to be allowed in selectors. In particular, some of my selectors contain the "=" character in an attribute, but the quoting logic doesn't seem to handle this case properly.

comment:22 in reply to:  21 Changed 10 years ago by jitter

Replying to webmaster@…:

This "bug fix" doesn't seem to work correctly in all cases.

It seems that the modification made by this bug fix in the Sizzle function seems to choke on some of the meta-characters that are supposed to be allowed in selectors. In particular, some of my selectors contain the "=" character in an attribute, but the quoting logic doesn't seem to handle this case properly.

Please submit a reduced test case which reproduces the issue you are experiencing (ideally on http://jsfiddle.net). So that we can investigate this issue further.

comment:23 Changed 10 years ago by webmaster@…

Reduced test case.

http://jsfiddle.net/2KPBQ/

Under 1.4.3 and 1.4.4, it doesn't work, but does under 1.4.2. (Maybe the issue was introduced in 1.4.3, but I didn't notice).

comment:24 Changed 10 years ago by anonymous

Insignificant correction to test case.

http://jsfiddle.net/2KPBQ/1/

comment:25 Changed 10 years ago by jitter

Milestone: 1.4.41.4.5
Resolution: fixed
Status: closedreopened
Version: 1.4.31.4.4

test case which works under jQuery 1.4.2/1.4.3 but fails under 1.4.4

The testcase provided in comment 23/24 also work in 1.4.2/1.4.3 but fail under 1.4.4 (Opera 10.63 and FF 3.6.12 tested)

comment:26 Changed 10 years ago by jitter

Status: reopenedopen

comment:27 Changed 10 years ago by christian.fazzini@…

Additionally,

$("input[name=song[attachment]]").length returns 0

$("input[name='song[attachment]']").length returns 1

The first case used to work in 1.4.2 and is not working on 1.4.4. Is this being looked at as well?

comment:28 Changed 9 years ago by dmethvin

Milestone: 1.4.51.5

comment:29 Changed 9 years ago by john

Resolution: fixed
Status: openclosed

The additional issues that were brought up here were taken care of in #6093.

Note: See TracTickets for help on using tickets.