-
Notifications
You must be signed in to change notification settings - Fork 1
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
Separate root and child functions #11
Conversation
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.
While the single/multiple distinction would indeed be useful, I think the root/child distinction doesn't help with anything. Logically, there is no reason functions should work differently between child and root elements, and indeed, in your code only the update
function actually uses this distinction.
But there is no deep reason that update
should be prohibited on child elements. It's just an implementation quirk of Enzyme.
From the end user perspective, update
shouldn't even apply to any element in particular. Rather, it should affect "the world" (or, more precisely, the "current simulation").
There is no reason update
should be prohibited inside a withSelector
, quite the opposite: it creates an inconvenience. Now I have to exit the withSelector
context just to call waitUntil
Currently update
simply doesn't work inside a withSelector
, but instead of explicitly preventing it from being called there, we should make it work. I'm pretty sure there is a way to find the root element by repeatedly calling parent
, but even failing that, we can solve this by carrying around not just the "current" element, but the original root as well.
But the problem, I think, is how do you get the updated "current" element -- not just how to get the root. |
Ah, I think there is a bit of misunderstanding here. The But here's the kicker: apparently the Enzyme team had the same idea 3 years ago. Check this out: enzymejs/enzyme#1802 (comment) And the comment was updated too: https://github.com/enzymejs/enzyme/pull/1802/files#diff-380144706937206c2b8ef0761bb879bc2c25e6cb11b7b31dd0091e5c690f5fddR226 But the docs are apparently out of date now. |
Interesting, but then does that mean this already works? |
Yes, exactly |
Adds a
Wrapper
class, with two instances for root and child wrappers. This way, we can encode into the types whether a function has to run on the root wrapper, like update:I think this should also extend to other things, like:
But I haven’t thought too much about it, yet.