Skip to content

[SSR] DOM Shim Specification and / or Polyfill #55

@thescientist13

Description

@thescientist13

Overview

Breaking the SSR part off from #35 since there were a couple thoughts going on there and thought it might be better to keep them separate

As "Web Components" itself is an umbrella label for a subset of web standards and APIs native to browsers, it is an exercise left up to developers who want to server-render web components to shim the DOM themselves on the server, typically in a JavaScript (e.g. NodeJS) runtime. It would be nice as a community if we could define what a common set of reasonable Web Components and Web Components adjacent APIs for the server-side would like.

This could just be a documented spec / reference, or even a package that can be distributed out on npm for libraries and frameworks and to leverage.

Specification

I think first would be establishing what we would consider a reasonable set of shims to be for a server environment.

At the most basic, that would seem to include:

  • window / document
  • customElements.[define|get]
  • HTMLElement
  • addEventListener (no-op?)
  • HTMLTemplateElement
  • attachShadow
  • .[get|set|has]Attribute
  • <template> / DocumentFragment

Shared Polyfill

Much like the @webcomponentsjs family of polyfills, it would be nice for this CG to maintain / contribute this as a library that could be published to npm.

It would be nice if this is something that could be extended from so if libraries and frameworks want to add additional support on top of the baseline, they can offer that.

Prior Art

(please comment below and share others!)


(who knows, maybe we even "upstream" this into the WinterCG spec! 🤩 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions