刮刮前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

20 lines
492 B

const {
ID,
elements
} = require('../util')
const {
isComponent
} = require('../../util')
// 仅限 view 层
module.exports = function parseComponent (el) {
// 需要把自定义组件的 attrs, props 全干掉
if (el.tag && !elements.includes(el.tag) && isComponent(el.tag)) {
// 仅保留 id、ID、data
el.attrs && (el.attrs = el.attrs.filter(attr => {
const name = attr.name
return name === 'id' || name === ID || name.indexOf('data-') === 0
}))
}
}