Description
When a Pattern is imported in JavaScript and it is not yet registered, it will be registered in the Patternslib registry.
If the registry was already initialized the document would be scanned.
We probably want to prevent the auto-scanning when dynamically importing other patterns in JavaScript code.
See the following comment from this commit: plone/mockup@877c83a
TMP: move Select2 out of init. If it wasn't already registered, it would
register + scan the document now. If there were previous relateditems already
modifying the DOM structure and placing pat-select2 classes to some items, the
import here would try to initialize them. But those pat-select2 items were
meant to be initialized via JavaScript code and are missing some configuration
needed by select2 (query attribute...). By moving the Select2 out of the init
and importing it early fixes this problem.Btw. this happened in plone.app.mosaic with module federation. pat-select2 was
already directly imported by the main Mockup bundle. But since we didn't have a
global pattern registry, the pattern was re-initialized where it wouldn't have
to. Since the change in Patternslib with a global pattern registry this fix
might become obsolete. However, we should have an eye on dynamic pattern
imports immediately registering and scanning the docment and possibly prevent
that in some way.