attrs.js 544 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7
const {
  IDENTIFIER_ATTR
} = require('../../../constants')

const getMemberExpr = require('../member-expr')

module.exports = function processAttrs (paths, path, state, isComponent, tagName) {
fxy060608's avatar
fxy060608 已提交
8
  const attrsPath = paths.attrs
fxy060608's avatar
fxy060608 已提交
9 10 11 12 13 14 15 16 17 18
  if (attrsPath) {
    attrsPath.get('value.properties').forEach(propertyPath => {
      const valuePath = propertyPath.get('value')
      if (valuePath.isObjectExpression()) {
        valuePath.replaceWith(getMemberExpr(null, IDENTIFIER_ATTR, valuePath.node, state))
      }
    })
  }
  return []
}