fix(Form):Form 表单在 Web 下缺乏 type=“submit” 属性#17892
fix(Form):Form 表单在 Web 下缺乏 type=“submit” 属性#17892felix9ia wants to merge 2 commits intoNervJS:mainfrom
Conversation
## Walkthrough
移除了 `specialElements` 中 `button` 元素的完整映射条目,改为在 `modifyHydrateData` 钩子中针对 `input` 和 `button` 元素的 `type` 属性为 `"submit"` 或 `"reset"` 时,动态添加 `formType` 属性。
## Changes
| 文件/分组 | 变更摘要 |
|------------------------------------------------|------------------------------------------------------------------|
| packages/taro-plugin-html/src/constant.ts | 移除 `specialElements` 中 `button` 条目及其 `mapName` 和 `mapAttr` 实现。 |
| packages/taro-plugin-html/src/runtime.ts | 在 `modifyHydrateData` 钩子中新增逻辑,为 `input` 和 `button` 元素的 `type` 为 `"submit"` 或 `"reset"` 时,添加 `formType` 属性。 |
## Poem
> 小兔轻跳代码间,
> 按钮映射去旧颜。
> 类型提交添新意,
> 表单行为更自然。
> HTML 细节巧安排,
> 功能完善乐开怀!
> 🐇💻✨📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| mapAttr (key, value, props) { | ||
| if (key === 'type' && (value === 'submit' || value === 'reset')) { | ||
| key = 'formType' | ||
| props.formType = value |
There was a problem hiding this comment.
@yoyo837 确实看起来很 hack,但是能生效🤦♂️
我没有找到比这个位置更好的挂载点来同时支持这两个属性.....很苦涩。
如果有更好的实现方式,请指出,我来改。
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (54.99%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #17892 +/- ##
=======================================
Coverage 54.99% 54.99%
=======================================
Files 417 417
Lines 21696 21696
Branches 5358 5360 +2
=======================================
Hits 11931 11931
+ Misses 8090 8083 -7
- Partials 1675 1682 +7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
| data.formType = data.type | ||
| } | ||
| // button[type=submit|reset] 时,额外添加 formType 属性 | ||
| if (nodeName === 'button' && (data.type === 'submit' || data.type === 'reset')) { |
这个 PR 做了什么? (简要描述所做更改)
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台:
Summary by CodeRabbit