Open domenic opened 7 years ago
It's not spec'ed anywhere. It's sort of a suggestion that shadowroot
element could be implemented that way if we had such a callback which gets called for a template "declaration".
@rniwa what is template "declaration" and do you think we should include it in v1? I don't really have a sense of whether it's an easy addition or a hard one.
We recently needed to add a callback to lit-html with the same timing as declareCallback
to modify the template for various polyfills. Seems really useful in a number of other scenarios too, especially for custom template processors to do one-time work.
To offer an example related to what @justinfagnani suggested about one-time work:
Many types of template expressions will need to be parsed before they can be used in the template processor. It will be ideal if each expression is only parsed once per part per unique template. A declareCallback
would be a nice spot to do this kind of thing.
This was used in the declarative shadow root example, but doesn't seem to appear elsewhere.