Skip to content

Commit 78ccb87

Browse files
jessejyanganchengjian
authored andcommitted
fix: #429 表单元素存在子元素改为不闭合
1 parent 29cee1a commit 78ccb87

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/platforms/mp/compiler/codegen/generate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function generate (obj, options = {}) {
1919
const attrs = Object.keys(attrsMap).map(k => convertAttr(k, attrsMap[k])).join(' ')
2020

2121
const tags = ['progress', 'checkbox', 'switch', 'input', 'radio', 'slider', 'textarea']
22-
if (tags.indexOf(tag) > -1) {
22+
if (tags.indexOf(tag) > -1 && !(children && children.length)) {
2323
return `<${tag}${attrs ? ' ' + attrs : ''} />${ifConditionsArr.join('')}`
2424
}
2525
return `<${tag}${attrs ? ' ' + attrs : ''}>${child || ''}</${tag}>${ifConditionsArr.join('')}`

test/mp/compiler/index.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,13 @@ describe('表单', () => {
453453
{ name: 'a' }
454454
)
455455
})
456+
it('radio', () => {
457+
assertCodegen(
458+
`<radio><text>233</text></radio>`,
459+
`<template name="a"><radio class="_radio"><text class="_text">233</text></radio></template>`,
460+
{ name: 'a' }
461+
)
462+
})
456463
})
457464

458465
describe('template', () => {

0 commit comments

Comments
 (0)