Attrs are never observed unless added with `@attr` decorator
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
从 src/attr.ts 开始,重点查看 defineObservedAttributes() 和 getAttrNames(),然后将它们的行为与 docs/_guide/attrs.md 中的 vanilla 示例进行比较。确认手动初始化的属性是否可以在没有 @attr 的情况下被观察;当实现和指南对如何指定被观察的属性达成一致时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Hi folks,
While I was testing the attributes — trying to work my way around #207 — I found another subtle detail. Manually initialized attributes are never observed.
Catalyst's guide provides the following example for vanilla users: https://github.com/github/catalyst/blob/main/docs/_guide/attrs.md#what-about-without-decorators.
Please notice the second argument there defineObservedAttributes(HelloWorldElement, ['foo']) and compare it with the actual function declaration:
https://github.com/github/catalyst/blob/a8fb3ba59a4ac258d0fe64a50ecd3b6997f5f016/src/attr.ts#L99
It doesn't expect the second argument (arguments aren't used either).
Now, internally defineObservedAttributes() pulls attribute names from getAttrNames(), which, in turn, pulls them from attrs (WeakMap). The only way to populate attrs is to use @attr decorator:
https://github.com/github/catalyst/blob/a8fb3ba59a4ac258d0fe64a50ecd3b6997f5f016/src/attr.ts#L15
Maybe I'm missing something, but it seems like there's no way to specify observed attributes without decorators. In any case, it'd be very nice to clarify that 🙂
Thank you!
- 主要语言
- TypeScript
- 星标
- 1.4k
- 派生
- 61
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 8
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/catalyst 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 3/5 1-2 天 新手友好度 62/100
-
难度 5/5 一周以上 新手友好度 20/100
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 42/100
相似的 Issue
-
normalizePropName strips `#` characters from Figma property names instead of only the `#id` suffix未关闭
难度 2/5 1-3 小时 新手友好度 72/100
figma/code-connect#419 ·
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
jeanibarz/knowledge-base-mcp-server#1268 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 78/100
Koenkk/zigbee-herdsman-converters#13820 ·
维护者通常 2 天内回复
-
A live recovery copy treats a large whole number and text with the same digits as the same value未关闭bug sharing & sync
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
[prefer-expect-resolves] autofix leaves a stray ")" when the awaited expression is parenthesized未关闭
难度 2/5 1-3 小时 新手友好度 78/100
jest-community/eslint-plugin-jest#2052 ·