lit / lit/lit

[labs/scoped-registry-mixin] Provide a method that allows lazy scoping of elements

Open
#3,574 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
21.8k
Forks
1.1k
Avg merge
18h 25m
Merged PRs (30d)
2

Description

### Should this be an RFC?

- [X] This is not a substantial change

### Which package is this a feature request for?

@lit-labs/scoped-registry-mixin

### Description

In some situations you may want to use a component in your templates that is not already loaded at the moment of defining the scoped elements map. It would be nice to provide a defineScopedElement method to define scoped elements at any time.

This is how the @open-wc library implemented a way to lazily created scoped elements:

https://open-wc.org/docs/development/scoped-elements/#lazy-scoped-components

```js
this.defineScopedElement('my-button', MyButton)
```

### Alternatives and Workarounds

There doesn't appear to be a workaround in this library to achieve this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the @lit-labs/scoped-registry-mixin package by reading how the scoped elements map is defined and how elements are currently registered. Compare the requested behavior with the linked open-wc lazy-scoped-components approach. Done means a defineScopedElement method can register an element after the scoped map is defined, with tests covering that use case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.