-
Notifications
You must be signed in to change notification settings - Fork 264
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
fix: record native events against each wrapper they bubble through #394
fix: record native events against each wrapper they bubble through #394
Conversation
|
||
this.attachNativeEventListener() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this method should be exported from emit.ts
with this
as an argument, the style looks very different from anything else so I tried to add a private method instead. There is definitely some bleeding of concerns.
const vm = this.vm | ||
if (!vm) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling this.element
breaks in some circumstances that I had trouble debugging, for some reason findComponent
creates Wrapper objects without a vm? Anyway, if there's no vm, I guess there's nothing to bind event listeners to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot imagine why this would happen 🤔 I will look at it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it makes sense, functional components can be found with findComponent
but they do not have a vm
most likely someone is going to ask about capturing emitted events from functional components. let's deal with it if and when it comes up 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test I added has a functional component for the grandparent, which works because it captures events that bubbled to the element of the outer wrapper, I suppose. It might be different for functional components without their own native DOM element but I suppose in that case DOM events wouldn't expect to be captured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good!
Seems we need more investigation - I ran #391 against this PR and it does not pass, I get a weird output:
I am starting to think this problem is unique to compositionstart and compositionend. I wonder if jsdom does not implement these... but it was ok with the emitMixin method. What is going on! Click and other native events are working fine. Okay found it... this is the problem:
For some reason |
I found this fix. I cannot push to your branch. Are you able to enable the setting "let maintainers push commits" (not sure the exact name of the setting). |
Sorry @lmiller1990 I don't see the "Allow maintainers..." option on the PR. Apparently it won't work on this PR because it's underneath an Organisation (isaacs/github#1681), next time I'll make sure it's a user repo. I'll make the changes you requested, and if you want to keep riffing on it we can figure out another solution. Maybe I'll re-create it as a user fork. |
Should be fine, I will give this one last test and merge it. If we need to make any tweaks we still have a few release candidates up our sleeve :) thanks for this! |
Sounds good! Thanks for your help getting it over the line. |
fix #391
This is pretty ugly on a few levels and I think it needs some cleaning up, but I think it addresses the issue. Maybe going back to the old mixin is a better idea for native events, I think I'll leave that up to you because you know the history a bit better.
I added a test that covers I think a basic exploration of the problem being solved.
Again, I'm an absolute TS novice, 🙏 for me.
Looking at this code again, do we need to add a way to clear events similar to jest's
mockClear()
?