提交 74d68d1b 编写于 作者: fxy060608's avatar fxy060608

fix(cli): ignore id,class,style,inline-template (bool-attr)

上级 6b46f260
...@@ -649,8 +649,8 @@ describe('mp:compiler-extra', () => { ...@@ -649,8 +649,8 @@ describe('mp:compiler-extra', () => {
}) })
it('generate bool attr', () => { it('generate bool attr', () => {
assertCodegen( assertCodegen(
'<video controls/>', '<video id class style inline-template controls/>',
'<video controls="{{true}}"></video>' '<video id controls="{{true}}"></video>'
) )
assertCodegen( assertCodegen(
'<video controls=""/>', '<video controls=""/>',
......
const dirRE = /^v-|^@|^:|^#/ const dirRE = /^v-|^@|^:|^#/
const PROPS = ['id', 'class', 'style', 'inline-template']
module.exports = { module.exports = {
preTransformNode (el) { preTransformNode (el) {
if (!el.attrsList) { if (!el.attrsList) {
...@@ -7,7 +9,7 @@ module.exports = { ...@@ -7,7 +9,7 @@ module.exports = {
} }
el.attrsList.forEach(attr => { el.attrsList.forEach(attr => {
if (attr.bool) { if (attr.bool) {
if (!dirRE.test(attr.name) && attr.name !== 'inline-template') { if (!dirRE.test(attr.name) && !PROPS.includes(attr.name)) {
delete el.attrsMap[attr.name] delete el.attrsMap[attr.name]
attr.name = ':' + attr.name attr.name = ':' + attr.name
attr.value = 'true' attr.value = 'true'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册