Skip to content

[labs/ssr] ElementRenderer interface should have getAttributes() #3630

@augustjk

Description

@augustjk

Should this be an RFC?

  • This is not a substantial change

Which package is this a feature request for?

SSR (@lit-labs/ssr)

Description

From PR review here: #3605 (comment)

When getting attributes after connectedCallback() is useful for grabbing reflected attributes. While renderAttributes() exists, it would be nice to be able to get the attributes in a more convenient format, whether as NamedNodeMap as Element.attributes returns, or as an object. This was needed for SSR integration with React where the host element rendering is delegated to React and so the attributes needed to be passed to React as part of the props object.

Alternatives and Workarounds

rendererInstance.element?.attributes.

But as noted here

export abstract class ElementRenderer {
// TODO (justinfagnani): We shouldn't assume that ElementRenderer subclasses
// create an element instance. Move this to a base class for renderers that
// do.
element?: HTMLElement;

we shouldn't expect .element to always be there.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

📋 Triaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions