github / github/markdown-toolbar-element
Element should not auto-register itself unless a browser context is found
- Langage dominant
- JavaScript
- Étoiles
- 411
- Forks
- 60
- Merge moyen
- 2 j 22 h
- PR mergées (30 j)
- 6
Description
Per discussion in https://github.com/primer/react/pull/2339, the fact that this element automatically registers itself at the top level makes it incompatible with server-side rendering, where JavaScript might be run outside of a browser context.
> From an SSR perspective, adding a simple `typeof window !== 'undefined'` guard should be sufficient. However, that won't solve the fact that the markdown-toolbar-element currently executes with side-effects, and thus cannot be tree-shaken. This means bundles in dotcom that do not need toolbar element will carry it as extra weight that is not needed. We would need to add a `register()` function to allow tree shaking, which would be a breaking change on the web component package.
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Start by reading the discussion in pull request 2339 and the registration behavior described in this issue. Define whether the change should only guard browser access or also introduce an explicit register() API; done should address server-side rendering and avoid unnecessary toolbar-element side effects without leaving the package behavior unresolved.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript
- Domaine
- frontend, web-dev
- Type d'issue
- Refactorisation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 28/100