adobe / adobe/react-webcomponent
Default model values are passed for attributes that are not present
- 主要语言
- JavaScript
- 星标
- 104
- 派生
- 20
- PR 合并指标
- 30 天内没有已合并 PR
描述
### Expected Behaviour
If I have defined a model where I specify a boolean attribute. e.g. `@byBooleanAttrVal() checked`. And, I have an instance of my web component where I do not specify that attribute (e.g. . The props passed to my React components `render` method contain the `checked` prop set to the default value from the model definition.
### Actual Behaviour
I would expect any model attributes that are not specified to not be passed as props. Otherwise, I have no way of telling whether the user set that attribute or not.
### Reproduce Scenario (including but not limited to)
I was wrapping up a React implemented checkbox widget.
#### Steps to Reproduce
1. Create a React component that takes a boolean prop
2. Create a model for that component that uses `@byBooleanAttrVal()`
3. Instantiate the web component without using the boolean attribute from your model
4. Set a breakpoint in the `render` method of your React component
5. Look at the props and see that the boolean prop has been passed in
#### Platform and Version
Chrome 72
#### Sample Code that illustrates the problem
#### Logs taken while reproducing problem
贡献指南
调研方向
首先复现已记录的 custom-element 和 React render 场景,重点关注如何收集 model 属性并将其作为 props 传递。当省略的布尔属性不出现在 React props 中,而显式指定的属性仍以其预期值传递到 render 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, react
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100