Closed pittst3r closed 6 years ago
This is what I've wanted to do, but had no idea how 👍 . Love this, even if it's a short-term solution.
@robbiepitts, not sure if it's final yet but if you're going to remove @props
and this.args
then the section of the docs where it states
If you already have an app and you want to use it as a Web Component, install the following package using yarn:
should be removed so no future expectations will be implied to devs.
Please ignore if the plan to remove that is already in place. 😬
@rmmmp Thanks for pointing that out, I probably would have missed it. Definitely not final though. Pending feedback.
Closing, old and busted. This was experimental and probably not a good direction for @glimmer/web-component.
Requires:
Renders as fragment into the custom element’s
shadowRoot
Usage of the shadow DOM is required for slots, which we need if we want to have content in a custom element’s
innerHTML
. We render as a fragment because requiring a root element wrapping the content in theshadowRoot
doesn’t make sense. And the semantics of a regular layout imply that the layout contains the root element of the component. Which is not the case here. The root element of the component in this case is the custom element, which already exists and we are rendering the layout into it.Provides a
didAppendLayout
hook in place ofdidInsertElement
Since we are not inserting the element here; it’s already been inserted. We are rendering content into an already-existing element.
didAppendLayout
fires after the content is rendered into theshadowRoot
node of the custom element.Eagerly sets
element
property to custom elementThe custom element is available via the
element
property as early as the invocation of the constructor of the component class. From here one can access attributes and properties on the element and use them for initial or subsequent renders. The element properties and attributes are not tracked (changes to them will not trigger a rerender).Makes use of the feature-flagged
{{use-component-manager
pragmaOne must stick
{{use-component-manager “custom-element”}}
at the top of custom-element-enabled Glimmer component templates to make all this work because we are using a custom component manager.No
args
The
CustomElementComponentManager
removesthis.args
, since that is not a thing you can do with custom elements.