github / github/markdown-toolbar-element

Element should not auto-register itself unless a browser context is found

未关闭
#68 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
411
派生
60
平均合并
2 天 22 小时
30 天内合并 PR
6

描述

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.

贡献指南

打开贡献指南

调研方向

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.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript
领域
frontend, web-dev
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
28/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。