theKashey / used-styles

📝All the critical styles you've used to render a page.
MIT License
137 stars 9 forks source link

fix: add support for class names which are keys from object prototype #42

Closed nickolaj-jepsen closed 1 year ago

nickolaj-jepsen commented 1 year ago

This PR fixes an issue in astToUsedStyles, that would crash if it received a class name which also was a function in the Object.prototype eg. "toString", because lookup["toString"] would return a function, which would cause files.forEach to fail with the error TypeError: files.forEach is not a function

theKashey commented 1 year ago

😃 but how this className got there?

nickolaj-jepsen commented 1 year ago

smiley but how this className got there?

It surfaced during a fuzzing test of one of our components, don't worry we aren't using toString as a class name in production :wink:

Thanks for the fast merge and excellent library :slightly_smiling_face:

theKashey commented 1 year ago

As I understand there is no real need to release a new version with the fix. Let me hold it for a week and incorporate into the next update.