vercel / styled-jsx

Full CSS support for JSX without compromises
http://npmjs.com/styled-jsx
MIT License
7.7k stars 262 forks source link

Bugfix: handle undefined <style> tag attr.name #843

Open LucasMatuszewski opened 7 months ago

LucasMatuszewski commented 7 months ago

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 ;)