diff --git a/src/babel.js b/src/babel.js index 78d0c09..fd4fe7b 100644 --- a/src/babel.js +++ b/src/babel.js @@ -15,8 +15,8 @@ const STYLE_COMPONENT_ID = 'styleId' const STYLE_COMPONENT_CSS = 'css' export default function ({types: t}) { - const isGlobalEl = el => el.attributes.some(attr => ( - attr.name.name === GLOBAL_ATTRIBUTE + const isGlobalEl = el => el.attributes.some(({name}) => ( + name && name.name === GLOBAL_ATTRIBUTE )) const isStyledJsx = ({node: el}) => ( @@ -93,8 +93,11 @@ export default function ({types: t}) { name !== STYLE_COMPONENT && name.charAt(0) !== name.charAt(0).toUpperCase() ) { - for (const attr of el.attributes) { - if (attr.name === MARKUP_ATTRIBUTE || attr.name.name === MARKUP_ATTRIBUTE) { + for (const {name} of el.attributes) { + if (!name) { + continue + } + if (name === MARKUP_ATTRIBUTE || name.name === MARKUP_ATTRIBUTE) { // avoid double attributes return } diff --git a/test/fixtures/multiple-jsx.js b/test/fixtures/multiple-jsx.js index 2448134..0b1de33 100644 --- a/test/fixtures/multiple-jsx.js +++ b/test/fixtures/multiple-jsx.js @@ -1,6 +1,10 @@ +const attrs = { + id: 'test' +} + const Test1 = () => (
- test + test