styled-jsx icon indicating copy to clipboard operation
styled-jsx copied to clipboard

Bugfix: handle undefined <style> tag attr.name

Open LucasMatuszewski opened this issue 1 year ago • 0 comments

I've faced an issue when attr.name was undefined. For example when spreading an object inside the <style> tag like this:

<style {...(key && { key })} />

I got an error on the Storybook build:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
TypeError: /home/lucas/project-name/src/utils/withStyles.tsx: Cannot read properties of undefined (reading 'name')
    at /home/lucas/project-name/storybook/node_modules/styled-jsx/dist/babel/index.js:21535:26

And in the debugger:

Exception has occurred: TypeError: Cannot read properties of undefined (reading 'name')
  at /home/lucas/DEV/project-name/storybook/node_modules/styled-jsx/dist/babel/index.js:21535:26

I have applied the same fix as the one in isGlobalEl function from JJ Kasper (January 6th, 2019 6:09 PM).

Sorry, if I should create an issue first ;)

LucasMatuszewski avatar Feb 29 '24 04:02 LucasMatuszewski