File tree Expand file tree Collapse file tree
packages/babel-plugin-remove-jsx-attribute/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ const removeJSXAttribute = (api, opts) => ({
44 if ( ! opts . elements . includes ( path . node . name . name ) ) return
55
66 path . get ( 'attributes' ) . forEach ( attribute => {
7- if ( opts . attributes . includes ( attribute . node . name . name ) ) {
7+ const nodeName = attribute . node . name ;
8+ if ( nodeName && opts . attributes . includes ( nodeName . name ) ) {
89 attribute . remove ( )
910 }
1011 } )
Original file line number Diff line number Diff line change @@ -19,4 +19,13 @@ describe('plugin', () => {
1919 } ) ,
2020 ) . toMatchInlineSnapshot ( `"<div foo><span /></div>;"` )
2121 } )
22+
23+ it ( 'should not throw error when spread operator is used' , ( ) => {
24+ expect (
25+ testPlugin ( '<div foo><span foo {...props} /></div>' , {
26+ elements : [ 'span' ] ,
27+ attributes : [ 'foo' ] ,
28+ } ) ,
29+ ) . toMatchInlineSnapshot ( `"<div foo><span {...props} /></div>;"` )
30+ } )
2231} )
You can’t perform that action at this time.
0 commit comments