#14064 closed bug (notabug)
:eq return different object in 1.10.1
Reported by: | htpu | Owned by: | htpu |
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.10.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
For the following html dom:
<div id="container"> <div id="a"><div id="b"></div></div> <div id="c"><div id="d"></div></div> </div>
the following JS code:
$("#container > * :eq(1)")
returns div.#c in jquery 1.9.x but returns div.#d in jquery 1.10.1
Change History (5)
comment:1 follow-up: 2 Changed 10 years ago by
Owner: | set to htpu |
---|---|
Status: | new → pending |
comment:2 follow-up: 3 Changed 10 years ago by
Replying to dmethvin:
So which result do you like best? I have a preference for what 1.10 returns.
After carefully testing, I found it's a bug in 1.10.1
Two selectors returns different result '#container > *:eq(1)' returns: c '#container > * :eq(1)' returns: d Note the only difference is that in the 2nd selector there is a space between "*" and ":eq" But the two selectors return the same result, c, in 1.9.1, which is the correct behavior
Please test it at http://jsfiddle.net/nVUpc/2/
comment:3 follow-up: 4 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | pending → closed |
Replying to [email protected]…:
Two selectors returns different result '#container > *:eq(1)' returns: c '#container > * :eq(1)' returns: d Note the only difference is that in the 2nd selector there is a space between "*" and ":eq" But the two selectors return the same result, c, in 1.9.1, which is the correct behavior
The space between "*
" and ":eq(1)
" is not meaningless; it is a descendant combinator:
- "
#container > *:eq(1)
" matches the second element child of #container. - "
#container > * :eq(1)
" matches the second element in the list of all descendants of element children of #container (equivalent to "#container > * *:eq(1)
").
1.10.1 implements the correct behavior in http://jsfiddle.net/nVUpc/2/.
comment:4 Changed 10 years ago by
Replying to gibson042:
Replying to [email protected]…:
Two selectors returns different result '#container > *:eq(1)' returns: c '#container > * :eq(1)' returns: d Note the only difference is that in the 2nd selector there is a space between "*" and ":eq" But the two selectors return the same result, c, in 1.9.1, which is the correct behavior
The space between "
*
" and ":eq(1)
" is not meaningless; it is a descendant combinator:
- "
#container > *:eq(1)
" matches the second element child of #container.- "
#container > * :eq(1)
" matches the second element in the list of all descendants of element children of #container (equivalent to "#container > * *:eq(1)
").1.10.1 implements the correct behavior in http://jsfiddle.net/nVUpc/2/.
According to the document
A descendant combinator is whitespace that separates two sequences of simple selectors
Which are simple selectors? And which are not? Are "*" and ":eq" both simple selectors?
I think the prvious behavior is more reasonable since most developers would not care the space before ":eq" or ":last" or ":XXX"
comment:5 Changed 10 years ago by
http://www.w3.org/TR/css3-selectors/#descendant-combinators
Simple selectors are basically the "atoms" of selector expressions.
Edit: http://www.w3.org/TR/css3-selectors/#simple-selectors, rather
So which result do you like best? I have a preference for what 1.10 returns.