Sha256: e7ef4ea80d059ea2290aa19ada5b7c657570a62e82bf3c3cc9df8cbc01044d91
Contents?: true
Size: 586 Bytes
Versions: 9
Compression:
Stored size: 586 Bytes
Contents
// adds "prefix-" to each `id` attribute const {createMacro} = require('../../') module.exports = createMacro(wrapWidget) function wrapWidget({references, babel}) { const {types: t} = babel references.default.forEach(wrap => { wrap.parentPath.traverse({ JSXAttribute(path) { const name = path.get('name') if (t.isJSXIdentifier(name) && name.node.name === 'id') { const value = path.get('value') if (t.isStringLiteral(value)) value.replaceWith(t.stringLiteral(`macro-${value.node.value}`)) } }, }) }) }
Version data entries
9 entries across 9 versions & 3 rubygems