Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions packages/taro-plugin-html/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,5 @@ export const specialElements = new Map<string, string | SpecialMaps>([
}
return [key, value]
}
}],
['button', {
mapName: 'button',
mapAttr (key, value, props) {
if (key === 'type' && (value === 'submit' || value === 'reset')) {
props.formType = value
}
return [key, value]
}
}]
])
9 changes: 9 additions & 0 deletions packages/taro-plugin-html/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ hooks.tap('modifyHydrateData', (data, node) => {
}
}

// input[type=submit|reset] 时,额外添加 formType 属性
if (nodeName === 'input' && (data.type === 'submit' || data.type === 'reset')) {
data.formType = data.type
}
// button[type=submit|reset] 时,额外添加 formType 属性
if (nodeName === 'button' && (data.type === 'submit' || data.type === 'reset')) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoyo837 ,看看在这个位置修改,合适吗?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoyo837 有时间review 一下看新的 commit 是否合适

data.formType = data.type
}

if (nodeName === 'br') {
data[Shortcuts.Childnodes] = [{
[Shortcuts.NodeName]: '#text',
Expand Down