quicklink icon indicating copy to clipboard operation
quicklink copied to clipboard

Allow adding elements directly to the Intersection Observer

Open lfre opened this issue 6 years ago • 6 comments

Per the discussion here: https://github.com/GoogleChromeLabs/quicklink/issues/43.

For dynamic content, depending on the page structure the query options.el.querySelector('a'), could return links that were already observed/prefetched and now unobserved (thanks to https://github.com/GoogleChromeLabs/quicklink/pull/51).

I provided a couple of options here: https://github.com/GoogleChromeLabs/quicklink/issues/43#issuecomment-447595607

lfre avatar Dec 17 '18 14:12 lfre

Now it's working

xtreomass12 avatar Dec 22 '18 11:12 xtreomass12

@renosbest _

renosbest avatar Dec 22 '18 11:12 renosbest

I'm the maintainer of the Drupal module that integrates quicklink into the CMS. This would really help users of traditional server-rendered CMS' by allowing other components (modules) to tell Quicklink to prefetch their own URLs. So ++

mherchel avatar Feb 03 '19 16:02 mherchel

As mentioned before, every intersected link is unobserved to avoid multiple prefetched on it.

demianrenzulli avatar Nov 25 '19 17:11 demianrenzulli

@demianrenzulli This is different than #43. The point here is that dynamic elements added to the same container would increase the querySelectorAll call unnecessarily. This can be avoided by allowing an override of the whole querySelectorAll call. e.g:

const elements = options.links || (options.el || document).querySelectorAll('a');

Additionally, the current check could be improved by moving the toPrefetch.has earlier to avoid re-observing here.

Hope that helps to distinguish the 2 issues.

lfre avatar Nov 25 '19 18:11 lfre

Thanks for confirming this @lfre, and sorry for the confusion!

It seems like it makes sense to keep this open then, so it can be considered as an FR for a future version.

demianrenzulli avatar Nov 25 '19 19:11 demianrenzulli