Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expr.relative truncates prematurely #86

Closed
gibson042 opened this issue Jan 7, 2012 · 0 comments
Closed

Expr.relative truncates prematurely #86

gibson042 opened this issue Jan 7, 2012 · 0 comments
Labels

Comments

@gibson042
Copy link
Member

Copied from http://bugs.jquery.com/ticket/11109

Test case: http://jsfiddle.net/JBBM8/

Because Sizzle.selectors.relative functions "return" only a single match, Sizzle can be trapped into a false negative with respect to preceding parts of the full selector when the relative selector tests against multiple elements (e.g., "~" and "").

I'm pretty sure that fixing this will require changing the Sizzle.selectors.relative Extension API to allow "returning" arrays, so I will hold off working on this until the core team weighs in with their comments/approval.

Technical explanation: Given a query like "A + B ~ C", Sizzle:

  1. Gets a set of all C, then
  2. Uses Sizzle.selectors.relative["~"] to replace each element with the first preceding sibling element matching B (or false if nonexistent), then
  3. Uses Sizzle.selectors.relative["+"] to replace each element with the preceding sibling element if it matches A (or false if it doesn't), then
  4. Returns all elements from the set at step 1 that stayed non-false through all subsequent steps

The problem here is that step 2 fails to report back all preceding siblings matching B, erroneously restricting the input set for subsequent step 3.

markelog pushed a commit to markelog/sizzle that referenced this issue May 26, 2013
…are left out. This is more accurate, but a little slower is some cases. -61 bytes compressed. Really fixes jQuery bug #11109. Closes jquerygh-86. Closes jquerygh-107.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants