Re-scan patternslib/mockup patterns in Plone 6 (ClassicUI)?

In ClassicUI, from JavaScript in an add-on resource, I want to re-scan DOM after manipulation with mockup for a .pat-plone-modal link that gets disconnected. The link is rendered by ZPT, but its parent element(s) are re-inserted into the DOM by a third-party JavaScript library.

In Plone 5, one would use AMD to get the registry and call its scan method.

In Plone 6, the registry has a scan method — but outside the tight-coupling of an ES6 module that actually lives in mockup (I am not writing a pattern) — I am quite unclear on if there is any mechanism for an add-on developer to write JavaScript that can request the registry to simply re-scan?

I quickly sum up our discussion from Discord here:

  • You cannot use the patternslib registry API without writing a pattern. (Feature request to patternslib?)
  • Use pat-inject to manipulate the DOM. This re-scans the inserted markup correctly.
  • Create your own pattern with plonecli to achieve complex usecases. I've started a documentation PR for this (see preview: Mockup and Patternslib – Classic UI — Plone Documentation v6.0)