Skip to content

[FEATURE] Implement Element's getHTML() to improve SSR of web components #317

@jackholden

Description

@jackholden

Hello,

As per #210 (comment), I am filing an issue to add support for getHTML().

Recently baseline (2024) across browsers, makes sense to implement in Linkedom. MDN

Element.getHTML({serializableShadowRoots: true})

Example

<hello-world>
    <span>Slotted Hello World!</span>
</hello-world>
class HelloWorld extends HTMLElement {
    constructor() {
        super();
        this.attachShadow({ mode: "open", serializable: true });
    }

    ....
}

Rendered as this:

<hello-world>
      <span>Slotted Hello World</span>
      <template shadowroot="open" shadowrootserializable="">
          <style>
              :host {
                  display: inline-block;
                  background: pink;
                  border: 2px dashed yellow;
              }
          </style>
          <div><slot></slot></div>
      </template>
</hello-world>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions