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

Trigger selectionchange event on document when selection changes (small change - 2 files) #3676

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

piotr-oles
Copy link

I want to test my contenteditable component that relies on selectionchange events. When debugging why my tests doesn't reflect browser behaviour, I found this TODO:
https://github.com/jsdom/jsdom/blob/main/lib/jsdom/living/selection/Selection-impl.js#L335

This PR addresses that TODO by triggering selectionchange event on document as stated in the spec. I added missing tests as well.

@piotr-oles piotr-oles changed the title Trigger selectionchange event on document when selection changes Trigger selectionchange event on document when selection changes (small change - 2 files) Jan 30, 2024
@piotr-oles
Copy link
Author

There is a timeout on node-canvas - I'm not sure if it's just flaky test

@piotr-oles
Copy link
Author

@domenic could you take a look? :)

@domenic
Copy link
Member

domenic commented May 26, 2024

Based on https://jsbin.com/qiyexuxoro/edit?html,output, the test does not seem to be valid. (Or at least does not match Firefox and Chrome behaviors.)

@domenic
Copy link
Member

domenic commented May 26, 2024

One guess is that the spec says to schedule the event by queuing a task, whereas this fires it immediately. In jsdom we often emulate this sort of task queuing by doing window.setTimeout(,0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants