Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#9776 closed bug (duplicate)

jQuery can't select elements by completely valid CSS selector and alternatively makes unwished DOM element

Reported by: miya2000 Owned by: Rick Waldron
Priority: high Milestone: 1.next
Component: core Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

Description

I posted a ticket but it was rejected as a sapn. So I write it my blog and link it.

http://d.hatena.ne.jp/miya2000/20110707/p0

jQuery Result: http://jsfiddle.net/nH26U/1/

Change History (7)

comment:2 Changed 6 years ago by Rick Waldron

Owner: set to miya2000
Status: newpending

Is there anyway you could reduce that overkill to something simple and straight forward that merely illustrates the issue...?

comment:3 Changed 6 years ago by Rick Waldron

Reduced test case:

http://jsfiddle.net/rwaldron/wFJ8N/

FWIW, I think it's obscene that HTML5 puts no restrictions on the characters that can be used in attribute values

comment:4 in reply to:  3 Changed 6 years ago by miya2000

Status: pendingnew

Thanks a lot! I didn't know that Firebug Lite is available. It is very simple!

FWIW, I think it's obscene that HTML5 puts no restrictions on the characters that can be used in attribute values

I think so, too about "class" attribute. But attributes are not only "class". "value" and "data-*" attributes are expected to store any data. And it is possible to include every attributes in a query selector.

http://jsfiddle.net/dFJwx/2/

And jQuery document says:

http://api.jquery.com/category/selectors/ If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]`{|}~ ) as a literal part of a name, you must escape the character with two backslashes:
.

So I think it should be fixed.

This problem is caused by existing two context, "Selector" and "DOM creation", in a same signature $(string).

I think jQuery's main work is Selector. But DOM creation interrupts it.

Fortunately, There is no selector starts with '<'. So I agree with suggestion in #9521. Do you think it has any problem in this suggestion?

Thank you.

comment:5 Changed 6 years ago by Rick Waldron

Component: unfiledcore
Owner: changed from miya2000 to Rick Waldron
Priority: undecidedhigh
Status: newassigned

First of all, I think you misunderstood me - I said nothing about "class" attributes specifically; I meant _all_ attributes. It has nothing to do with the sizzle/selectors, but everything to do with the regular expression used to determine which branch of logic should be used.

comment:6 Changed 6 years ago by Rick Waldron

Resolution: duplicate
Status: assignedclosed

Closing as duplicate, however this is not a 1-to-1 duplicate, simply that fixing 9521 will also resolve this issue

comment:7 Changed 6 years ago by Rick Waldron

Duplicate of #9521.

Note: See TracTickets for help on using tickets.