Skip to main content

Bug Tracker

Side navigation

#14064 closed bug (notabug)

Opened June 24, 2013 02:20AM UTC

Closed June 28, 2013 01:01PM UTC

Last modified July 01, 2013 03:00PM UTC

: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

Attachments (0)
Change History (5)

Changed June 24, 2013 02:51AM UTC by dmethvin comment:1

owner: → htpu
status: newpending

So which result do you like best? I have a preference for what 1.10 returns.

Changed June 28, 2013 07:38AM UTC by htp2008@gmail.com comment:2

Replying to [comment:1 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/

Changed June 28, 2013 01:01PM UTC by gibson042 comment:3

resolution: → notabug
status: pendingclosed

Replying to [comment:2 htp2008@…]:

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/.

Changed June 29, 2013 08:24AM UTC by htp2008@gmail.com comment:4

Replying to [comment:3 gibson042]:

Replying to [comment:2 htp2008@…]: > 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"

Changed July 01, 2013 03:00PM UTC by gibson042 comment:5

_comment0: http://www.w3.org/TR/css3-selectors/#descendant-combinators \ \ Simple selectors are basically the "atoms" of selector expressions.1372691463764008

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