I looked into using text-fragments-polyfill's processTextFragmentDirective with jsdom to translate a text fragment URL to a range (so that we can get a quotation from the range.) But it took over 60s to complete. So for now we are using extractQuotationFromTextFragment (dom-anchor-text-quote.)
See howdju-text-fragment's getRangesForCurrentFragment and extractQuotation.test.ts.
I didn't see anything obviously wrong with the implementation. I am not sure if it's a problem with the algorithm in text-fragments-polyfill or maybe an incompatibility with jsdom.
I took a breakpoint-based CPU profile which indicated that most the time was spent in jsdom's compareBoundaryPointsPosition:
I looked into using
text-fragments-polyfill
'sprocessTextFragmentDirective
withjsdom
to translate a text fragment URL to a range (so that we can get a quotation from the range.) But it took over 60s to complete. So for now we are usingextractQuotationFromTextFragment
(dom-anchor-text-quote
.)See
howdju-text-fragment
'sgetRangesForCurrentFragment
andextractQuotation.test.ts
.I didn't see anything obviously wrong with the implementation. I am not sure if it's a problem with the algorithm in
text-fragments-polyfill
or maybe an incompatibility withjsdom
.I took a breakpoint-based CPU profile which indicated that most the time was spent in
jsdom
'scompareBoundaryPointsPosition
: