Closed samdenty closed 1 month ago
As node-ids are simply integers, it's useful to be able to compare two ids to see which one appears first in the tree
Is it? By which definition of "first"?
specifically I need ord to compare two html elements in scraper, to see if an element is before / after another. In scrapers case it appears the ids are correlated to the order at which they appear in the dom.
let b_appers_after_a = a_ref.id() < b_ref.id()
There is no guarantee in either this library or scraper that the value of a NodeId would tell you that. NodeId's can be created in arbitrary order regardless of where they end up in the tree, and in particular the TreeSink trait which html5ever uses to build the tree decouples node creation from attaching to the tree in various ways.
As node-ids are simply integers, it's useful to be able to compare two ids to see which one appears first in the tree