Skip to content

Commit

Permalink
fix(babel-plugin): fix usage of spread attribute(#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
snags88 authored and gregberge committed Nov 13, 2018
1 parent 56241b3 commit 4186953
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/babel-plugin-remove-jsx-attribute/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const removeJSXAttribute = (api, opts) => ({
if (!opts.elements.includes(path.node.name.name)) return

path.get('attributes').forEach(attribute => {
if (opts.attributes.includes(attribute.node.name.name)) {
const nodeName = attribute.node.name;
if (nodeName && opts.attributes.includes(nodeName.name)) {
attribute.remove()
}
})
Expand Down
9 changes: 9 additions & 0 deletions packages/babel-plugin-remove-jsx-attribute/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,13 @@ describe('plugin', () => {
}),
).toMatchInlineSnapshot(`"<div foo><span /></div>;"`)
})

it('should not throw error when spread operator is used', () => {
expect(
testPlugin('<div foo><span foo {...props} /></div>', {
elements: ['span'],
attributes: ['foo'],
}),
).toMatchInlineSnapshot(`"<div foo><span {...props} /></div>;"`)
})
})

1 comment on commit 4186953

@vercel
Copy link

@vercel vercel bot commented on 4186953 Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://svgr-cxijpacanc.now.sh to the following alias.

Please sign in to comment.