imported-template
imported-template copied to clipboard
Change lifecycle
Currently we do all the work (importing, fetching and stamping elements, attaching the model) on attachedCallback.
What if we:
- Import nodes on
createdCallbackand every contentattributeChangeCallbackeven when detached - Attach model on
createdCallback, every modelattributeChangeCallback, once new content is imported, before it's (re-)stamped. - Attach nodes after element is atached
- Detach nodes once element is detached (keeping the reference)
@warpech @miyconst WDYT?
Benefits:
- we could start importing content sooner => improve FOUC
- we could access the imported content before stamping in more gently way (default layouts for
juicy-composition) - we could easier move
imported-template-scopemagic to separate component, that will plug-in to this
Risks/Doubts:
- imported elements will be created before attached to main document, so if they well created with such assumption they mail fail (however it is a bad practice anyway)
- flow may seem more tangled (however, I believe that with proper explanation in may be easy to get)