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

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

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