Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CE attribute rendering. #66

Open
wants to merge 2 commits into
base: hn-ssr-support
Choose a base branch
from

Conversation

kevinpschaaf
Copy link
Contributor

@kevinpschaaf kevinpschaaf commented Jul 7, 2020

  • Adds minimal attribute API to the dom-shim
  • Refactored custom-element opcodes:
    • custom-element-open creates ElementRenderer and CE instance and calls ElementRenderer:setAttribute() for all static attributes
    • attribute-part: runs in between the custom-element-open and custom-element-attributes opcodes, to ensure any property/attribute bindings are set on the element before serializing the attributes
    • custom-element-attributes: runs ElementRenderer:connectedCallback(), and then renders attributes via ElementRenderer:renderAttributes() (default implementation serializes the dom-shim's attributes collection)
    • custom-element-children: renders the CE children via ElementRenderer:renderAttributes()
  • lit-element-renderer.ts no-ops the client-side LitElement.render, and then implements new connectedCallback and attributeChangedCallback abstract methods to call protected UpdatingElement lifecycle.
  • Note that LitElement:performUpdate() is called with a new flag to elide the (first)updated callbacks, since these (a) can't do anything good to the SSR output since they occur after render(), and (b) may more likely touch DOM.
  • Escapes all attribute & textContent values (resolves TODO in code)

* Adds minimal attribute API to the dom-shim
* custom-element opcodes refactored:
  * `custom-element-open` creates `ElementRenderer` and CE instance and calls `ElementRenderer:setAttribute()` for all static attributes
  * `attribute-part`: runs in between the `custom-element-open` and `custom-element-attributes` opcodes, to ensure any property/attribute bindings are set on the element before serializing the attributes
  * `custom-element-attributes`: runs `ElementRenderer:connectedCallback()`, and then renders attributes via `ElementRenderer:renderAttributes()` (default implementation serializes the dom-shim's attributes collection)
  * `custom-element-children`: renders the CE children via `ElementRenderer:renderAttributes()`
* `lit-element-renderer.ts` no-ops the client-side `LitElement.render`, and then implements new `connectedCallback` and `attributeChangedCallback` abstract methods to call protected `UpdatingElement` lifecycle.
* Note that `LitElement:performUpdate()` is called with a new flag to elide the `(first)updated` callbacks, since these (a) can't do anything good to the SSR output since they occur after `render()`, and (b) may more likely touch DOM.
* Adds `SSRRenderOptions` to `render()`, and if `deferChildHydration` is true, it outputs a `defer-hydration` attribute on each CE
* Escapes all attribute & textContent values (resolves TODO in code)
@kevinpschaaf kevinpschaaf changed the title Add support for CE attribute rendering and defer-hydration. Add support for CE attribute rendering. Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant