-
Notifications
You must be signed in to change notification settings - Fork 0
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
FYI, my quick and dirty implementation (non-critical usage, so largely untested at this stage) #1
Comments
@danielweck Nice one Daniel. FYI I'm using treewalker to attempt to harness its ability to give me a custom view of the tree. I'm gaining understanding from the spec: https://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html#TreeWalker |
My next plan is to port a streamlined CFI test suite and bring it here. |
Tree Walker / Visitor Pattern is a nice abstraction, which I use in another project to navigate a complex hierarchy. It certainly makes sense to use this for a DOM tree :) PS: the code snippet I pasted here originally contains a "blacklist" check for DOM elements (identifiable by ID or CSS class) that are injected by the reading system / not part of the publication document. I removed the |
Perhaps I should point out that I also use code that converts DOM range to CFI equivalent. This code however is non-critical (untested) as the CFI is provided only for informational purposes. My ad-hoc DOM range JSON serialization format actually relies on CSS Selectors to reference parent elements, and indices for text nodes. It is pretty simple, and much more performant than encoding via CFI. |
Like Tiny-CFI, this also only supports DOM elements, but with ID assertions (yeah!) :)
(internally I use a custom DOM-Range JSON serialization format, so I have not relied on CFI much, other than for informational purposes ... but CFI can indeed be a useful interoperable "standard" in some cases, so I would love to see a complete mini-footprint robust implementation that includes support for character ranges ;)
tiny-cfi:
tiny-cfi/tinycfi.js
Lines 1 to 41 in e9fc323
The text was updated successfully, but these errors were encountered: