mh-two-thousand-and-two
2024-04-12 3d2ec2fd0578d3ba0a414b0cc4e4a2ae60878596
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
    }))
  }
}