feat(Platform): allow DI override of userAgent
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 91
描述
### Feature Description
Right now it is hardcoded as global `navigator.userAgent`:
https://github.com/angular/components/blob/main/src/cdk/platform/platform.ts
However in SSR there's a way to get userAgent from the request and accessing global entities is bad practice. Would be great if there was a token for userAgent [like we do here](https://github.com/taiga-family/ng-web-apis/blob/main/libs/common/src/tokens/user-agent.ts), or maybe at least `inject(DOCUMENT).defaultView?.navigator?.userAgent` way of accessing it, rather than just global `navigator.userAgent`
### Use Case
_No response_
贡献指南
调研方向
Start in src/cdk/platform/platform.ts, where the global navigator.userAgent access is defined, and inspect the surrounding platform injection setup. Compare the requested injectable user-agent source with the existing DOCUMENT access and verify the result in SSR while preserving browser behavior; done means callers can override the user agent through DI.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100