Issue 43 in fizzler: Multiple-selector doesn't return elements in document order

4 views
Skip to first unread message

fiz...@googlecode.com

unread,
Jan 16, 2011, 3:50:06 PM1/16/11
to fizzler...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 43 by HighTech...@gmail.com: Multiple-selector doesn't return
elements in document order
http://code.google.com/p/fizzler/issues/detail?id=43

http://api.jquery.com/multiple-selector/ states that for a
multiple-selector "The order of the DOM elements in the returned jQuery
object ... will be in document order."

Fizzler doesn't respect this order, instead returning all the matches for
each selector in turn and not in document order.

fiz...@googlecode.com

unread,
Jan 24, 2011, 4:30:03 PM1/24/11
to fizzler...@googlegroups.com

Comment #1 on issue 43 by edin.daz...@gmail.com: Multiple-selector doesn't

Is this behavior defined by CSS standard, or is it just a jQuery feature?

fiz...@googlecode.com

unread,
Jan 24, 2011, 5:42:22 PM1/24/11
to fizzler...@googlegroups.com

Comment #2 on issue 43 by HighTech...@gmail.com: Multiple-selector doesn't

Whilst jQuery does define this, the CSS spec does not appear to: CSS3 "A
comma-separated list of selectors represents the union of all elements
selected by each of the individual selectors in the list."

Since jQuery and Fizzler can be used to manipulate (and not just display)
documents it's arguably far more important that they each define an order
for how that union happens.

fiz...@googlecode.com

unread,
Jan 24, 2011, 8:12:50 PM1/24/11
to fizzler...@googlegroups.com

Comment #3 on issue 43 by azizatif: Multiple-selector doesn't return
Fizzler intentionally does not return the results in document order because
running a sort would end up buffering the results prior to yielding them.
This was done to maintain deferred execution semantics as much as possible
and make the caller pay for only the least necessary computation. For cases
where document order is significant, it seemed reasonable to let the caller
compose the results of QuerySelectorAll with OrderBy.

HtmlAgilityPack.HtmlNode has a StreamPosition property that can be used as
the key to get the results sorted in document order. Unfortunately, earlier
versions of HtmlAgilityPack also seemed to have an unreliable
StreamPosition so that was another (though lesser) reason for delegating
the decision to sort to the caller.

I am less concerned with jQuery. What Fizzler clearly violates is the
querySelectorAll contract specified as part of the NodeSelector[1]
interface and which states:

> The querySelectorAll() method on the NodeSelector interface
> must, when invoked, return a NodeList containing all of the
> matching Element nodes within the node’s subtrees, in
> document order.

One way forward I see is first have QuerySelectorAll return nodes in
document order. This way, there are no surprises but it will be clearly
returning buffered results (the inefficiency of which may in itself
surprise others). Then supply a non-normative alternative
(YieldQuerySelectorAll?) that does not guarantee document order but which
streams out the results.

[1] http://www.w3.org/TR/selectors-api/#nodeselector

fiz...@googlecode.com

unread,
Jan 24, 2011, 8:16:53 PM1/24/11
to fizzler...@googlegroups.com
Updates:
Status: Accepted

Comment #4 on issue 43 by azizatif: Multiple-selector doesn't return

(No comment was entered for this change.)

fiz...@googlecode.com

unread,
Aug 23, 2015, 9:45:36 AM8/23/15
to fizzler...@googlegroups.com

Comment #5 on issue 43 by azizatif: Multiple-selector doesn't return
elements in document order
https://code.google.com/p/fizzler/issues/detail?id=43

This issue has been migrated to:
https://github.com/atifaziz/Fizzler/issues/43
The conversation continues there.
DO NOT post any further comments to the issue tracker on Google Code as it
is shutting down.
You can also just subscribe to the issue on GitHub to receive notifications
of any further development.

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages