[doc] Document `context` packages ContextRoot
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 142
- Forks
- 230
- PR merge metrics
- No merged PRs in 30d
Description
While making the basic context example I ran into a footgun with element upgrade order or import order.
I made this example: https://lit.dev/playground/#gist=3ddd4d9368a408508f88a5ae328478a3
However due to the timing of component upgrading, the provider didn't work inside the <slot>, which confused me.
Having two script imports in the example fixed the issue, e.g.:
<script type="module" src="provider-element.js"></script>
<script type="module" src="consumer-element.js"></script>
But swapping the imports would again break the slotted consumer.
The fix for this situation is to add a ContextRoot and attach it to document.body.
Solution
ContextRoot is already documented: https://lit.dev/docs/data/context/#contextroot, however I think it could use some documentation above the API section with why you should use it and the tradeoffs.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the ContextRoot documentation page linked in the issue and read the existing API section alongside the linked playground example. Add introductory guidance explaining why to use ContextRoot, the element or import-order problem it addresses, and its tradeoffs; done means the page clearly prepares readers before the API reference.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100