microsoft / griffel

CSS-in-JS with ahead-of-time compilation ⚡️
https://griffel.js.org
MIT License
1.2k stars 61 forks source link

serializer: false matches, issues with trailing spaces #584

Closed layershifter closed 4 months ago

layershifter commented 4 months ago

Trailing space is not removed when there are other attributes

image

Regex there:

https://github.com/microsoft/griffel/blob/ec2b486b0e651f32a18a60f17d5a01b760febba5/packages/jest-serializer/src/index.ts#L59

Does not match as expected:

image

False positives

image

toString is a property on an object, check is not enough good there:

https://github.com/microsoft/griffel/blob/ec2b486b0e651f32a18a60f17d5a01b760febba5/packages/jest-serializer/src/index.ts#L66

Trailing space is not removed when markup has multiple elements

Only one trailing space gets removed:

<div class="class-reset-a class-reset-b">
  <div class="class-a class-b "></div> <!-- ⬅️ oops -->
</div>