-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
component.prop("id") returned with component.find("#foo") #1214
Comments
The selector API intentionally hits all nodes, host and composite - it's not a DOM, so the rule about "IDs are unique" doesn't really apply. What you probably want is #1179 - ie, |
That will do the trick, thanks for your quick response |
hostNodes is now released in v3.1 |
This just wasted several hours of my time. |
Isn't it pretty clearly wrong? There's one api for finding prop values, and a separate api for matching CSS selectors. Why would it be acceptable that they are mixed? A React component can't match a CSS selector because CSS selectors match html elements, which a React component isn't. I don't disagree that the solution is to use hostNodes(), but enzyme should be doing that internally when a string selector is given to find. I'd strongly recommend that this issue be reopened. |
What's more, |
enzyme is independent of react and of html. What would the selector api do with, say, react native? |
As far as the specific thing that doesn’t work for you, please file an issue and we’ll see if we can straighten it out. |
I have opened #1907 for the problems which occur regardless of this issue. |
Perhaps all that needs to be done is for there to be a convenience API, something like |
Is this a bug report?
Yes
Environment
[email protected]
Steps to Reproduce
When a component is mounted with JSDOM the selector library does not differentiate props.id and element.id
using react router as an example
Expected Behavior
I would not expect a custom component with the prop id to be returned when querying with a CSS selector.
test.findWhere(n => n.prop("id") === foo)
<-- expect to return 2 nodestest.find("#foo")
<-- expect to return a single nodeThe text was updated successfully, but these errors were encountered: