4 Matching Annotations
  1. Mar 2021
    1. The document.evaluate() method evaluates an XPATH query/expression. So you can pass XPATH expressions there, traverse into the HTML document and locate the desired element.
  2. Aug 2019
    1. Case in point: take this css selector: h1.header > a[rel~="author"] Its shortest functional XPath equivalent would be //h1[contains(" "+normalize-space(@class)+" "," header ")]/a[contains(" "+normalize-space(@rel)+" "," author ")] …which is both much harder to read and write. If you wrote this XPath instead: //h1[@class="header"]/a[@rel="author"] …you would incorrectly have missed markup like <h1 class="article header"><a rel="author external" href="/mike">...</a></h1>
    2. CSS syntax is awesome for two reasons: It is an order of magnitude faster and less resource intensive than the more complex XPath. When what you want to find can be found with a css selector, a corresponding XPath query doing the same would most of the time be much longer and harder to read.
  3. Apr 2016
    1. Interestingly, it uses multiple methods to locate the annotation within the cited page: absolute character count, text to search for, and XPath notation.

      That's done to accommodate sites who's DOM changes either over time or during user interaction (single page apps, etc).

      This blog post explains the current approach and thinking behind it in Hypothes.is: https://hypothes.is/blog/fuzzy-anchoring/