Re: [whatwg/dom] Add convenient, ergonomic, performant API for sorting siblings (#586)

> we need something that doesn't call back into JS for the simple cases, and as @annevk says, it should be an atomic operation from the DOM's perspective.

Wouldn't using [Anne's idea](#issuecomment-372090326) of describing the operation in terms of grouped transactions, even the JS comparator approach at least pass the second measure?

The only question is whether you'd run the comparator function (on all elements, to determine the abstract sort order) _before_ touching the DOM, or if you extract all the elements first, and sort them in a detached state.  The first approach makes it more "atomic", and allows you to use comparator functions that only work on attached elements, but any DOM-altering side effects in the comparator could make the sort order undefined.

> I'd suggest accepting numberish things rather than just numbers, so that you can get dates and dimensions and currency sorts (on normalized values) for free.

That seems to open up a lot of ambiguity. What determines the parsing rules for converting from string attribute values to the correct numeric type?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/586#issuecomment-373577809

Received on Friday, 16 March 2018 01:48:05 UTC