Skip to content

@primeuix/motion generates invalid CSS selector with empty segments when used with Tailwind v4 classes, breaking jsdom 28 #19456

@nrmopajaojvmoprej

Description

@nrmopajaojvmoprej

Describe the bug

When using p-date-picker (and likely other components that use @primeuix/motion for animations) in a Jest + jsdom 28 environment, the following error is thrown:

SyntaxError: 'div.min-w-1,,, .p-datepicker-input-icon-container' is not a valid selector

@primeuix/motion builds a CSS selector by reading the class list of the host element. When Tailwind v4 utility classes (e.g. min-w-1) are present alongside empty segments, the resulting selector contains ,, which is invalid CSS.

This was silently accepted by jsdom 27 (which used nwsapi) but jsdom 28 switched to @asamuzakjp/dom-selector which is stricter and throws on invalid selectors.

To Reproduce

  1. Use p-date-picker with [fluid]="true" and [showIcon]="true" inside a wrapper that has Tailwind v4 classes
  2. Use Jest with jest-environment-jsdom >= 28
  3. Interact with the datepicker in a test (e.g. click a button that triggers change detection after the datepicker renders)

Expected behavior

@primeuix/motion should filter out empty segments before joining class names into a CSS selector/

Environment

  • PrimeNG version: 21.1.2
  • Angular version: 21
  • @primeuix/motion version: 0.0.10
  • jsdom version: 28.1.0
  • Tailwind version: 4
  • Testing: Jest + @testing-library/angular + setupZonelessTestEnv

Workaround

Pinning jsdom to 27.3.0 via npm overrides in package.json restores the previous behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: TestIssue or pull request is related to Component TestingType: BugIssue contains a bug related to a specific component. Something about the component is not workingdependenciesIssue or pull request is related to a dependency packageprimeuix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions