EPA-WG / custom-element

Declarative Custom Element
Apache License 2.0
22 stars 1 forks source link

SRC attribute for DCE #19

Open sashafirsov opened 1 year ago

sashafirsov commented 1 year ago

Use cases:

sashafirsov commented 1 year ago

template content type

the content from remote server can be used as is in case the content is a pure XSLT. In this case all dependencies are resolved by XSLT engine. *

A relative path for xsl:include/@href or xsl:import/@href is resolved against the directory of the XSLT file that does the including or importing.

import maps

For HTML it has to be converted into XSLT first ( as inline DCE template ) with path resolution relative to imported file URL.

The path resolution has to be importmaps aware.

if (HTMLScriptElement.supports('importmap')) {
  // The importmap feature is supported.
}

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap

encapsulated import maps.

The standard does not support locally scoped maps. But in DCE if the imported HTML module has it, the context root(DCE) would be able to resolve URLs accounting as global as local import maps.

sashafirsov commented 1 year ago

Life cycle

in-page template

Same as embedded template case. Just instead of declaration payload, the template is taken by ID.

DCE instance

external template

when src is presented and points to external document:

external template fallback, error handler

The inline template would be used to render the DCE instance before the remote template loaded and XSLTProcessor created. Once the error happen during the load or creating the XSLTProcessor , the template data slice would be adjusted with the error and all DCE instances would receive the template change notification which would lead to trigger the transformation cycle.

If the inline template has the template.error handling, it would render the matching UI or ignore the error completely leaving the fallback UI.

default loading error appearance

DCE out of the box would display the template-error slot with debug info warning which would include the URL and potential error cause. The content can be overridden by providing custom template-error slot either on DCE declaration or on DCE instance level (samples TBD). The error suppressing can be done on DCE declaration payload level which would account the template/error data slice.

sashafirsov commented 1 year ago

external template loading sequence

Once templateRootS available, there are 3 choices:

sashafirsov commented 1 year ago

🤔 External template content. Take the whole, root element or children?