Skip to content

Commit

Permalink
fix: Meituan-Dianping#429 表单元素存在子元素改为不闭合
Browse files Browse the repository at this point in the history
  • Loading branch information
jessejyang authored and anchengjian committed Jun 15, 2018
1 parent 29cee1a commit 78ccb87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/platforms/mp/compiler/codegen/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function generate (obj, options = {}) {
const attrs = Object.keys(attrsMap).map(k => convertAttr(k, attrsMap[k])).join(' ')

const tags = ['progress', 'checkbox', 'switch', 'input', 'radio', 'slider', 'textarea']
if (tags.indexOf(tag) > -1) {
if (tags.indexOf(tag) > -1 && !(children && children.length)) {
return `<${tag}${attrs ? ' ' + attrs : ''} />${ifConditionsArr.join('')}`
}
return `<${tag}${attrs ? ' ' + attrs : ''}>${child || ''}</${tag}>${ifConditionsArr.join('')}`
Expand Down
7 changes: 7 additions & 0 deletions test/mp/compiler/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,13 @@ describe('表单', () => {
{ name: 'a' }
)
})
it('radio', () => {
assertCodegen(
`<radio><text>233</text></radio>`,
`<template name="a"><radio class="_radio"><text class="_text">233</text></radio></template>`,
{ name: 'a' }
)
})
})

describe('template', () => {
Expand Down

0 comments on commit 78ccb87

Please sign in to comment.