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

Why Sensors trigger events in source container? #539

Open
hnrq opened this issue Sep 6, 2022 · 4 comments
Open

Why Sensors trigger events in source container? #539

hnrq opened this issue Sep 6, 2022 · 4 comments

Comments

@hnrq
Copy link
Contributor

hnrq commented Sep 6, 2022

I'm still playing around with this lib and I saw that SensorEvents are usually triggered in source container and the target itself is set inside the event's details. This causes some errors when trying to use Happy DOM for testing, because target should be set once the event is dispatched and should not be overriden.

However, everything breaks when triggering Sensor Events on the target itself instead of the container and I'd like to do this replacement here, because it feels like it's the right pattern imo. Any ideas for making this replacement?

@zjffun
Copy link
Contributor

zjffun commented Sep 7, 2022

Which replacement not work? I try to replace one, it's work because we listen events on document.

@hnrq
Copy link
Contributor Author

hnrq commented Sep 7, 2022

Hmmm. That's probably because you kept this line. I was thinking about also removing these targets that are being passed to the Event itself

@zjffun
Copy link
Contributor

zjffun commented Sep 7, 2022

It seems we need to check all sensorEvent.target and related logic to achieve this replacement. Like zjffun@6cf6e81

@zjffun
Copy link
Contributor

zjffun commented Sep 7, 2022

Mainly need to check the logic of source element and original element. See #242
image

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

No branches or pull requests

2 participants