Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FocusTrap.js writes to read-only property classList which causes test failures under happy-dom #4015

Closed
bgoscinski opened this issue Jun 2, 2023 · 1 comment
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@bgoscinski
Copy link
Contributor

Describe the bug

When testing code that references FocusTrap.js with happy-dom as an environment the test fails with TypeError: Cannot assign to read only property 'classList' of object '[object Object]'. happy-dom implements only a getter for classList which is correct according to the MDN.

https://github.com/capricorn86/happy-dom/blob/f1987a9b442f6f288ad919dc6ed2331e2f3bc506/packages/happy-dom/src/nodes/element/Element.ts#L103-L108

Reproducer

n/a

PrimeVue version

3.29.1

Vue version

3.x

Language

ALL

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@bgoscinski bgoscinski added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 2, 2023
@bgoscinski
Copy link
Contributor Author

Workaround would be to run something like this before triggering FocusTrap.js code:

  // Extend Element.prototype to handle writes to classList property.
  // Workaround for https://github.com/primefaces/primevue/issues/4015
  const proto = Element.prototype
  const desc = Object.getOwnPropertyDescriptor(proto, 'classList')
  Object.defineProperty(proto, 'classList', {
    ...desc,
    set(value) {
      desc.get.call(this).value = value
    },
  })

@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jun 20, 2023
@tugcekucukoglu tugcekucukoglu added this to the 3.30.0 milestone Jun 20, 2023
@tugcekucukoglu tugcekucukoglu self-assigned this Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants