-
-
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
find by attribute doesn't work if string has a dot #590
Comments
The problem is with the regex that checks if the selector is compound. It doesn't take into account that attribute values can have the search items inside strings. It also doesn't recognize that names can have dashes and underscores. The solution is to match from the beginning of the selector up to the point where it has a compound marker. I tried to do a PR but got a whole bunch of errors trying to run the tests in the enzyme project. The fix is to change export const isCompoundSelector = /([a-z]\.[a-z]|[a-z]\[.*\]|[a-z]#[a-z])/i; To: export const isCompoundSelector = /^[\.#]?-?[_a-z]+[_a-z0-9-]*[\.\[#]/i; |
@ManuelDeLeon i changed the regex to your solution and added more test cases. |
Given this component:
The method
find
correctly identifies the first span with a data attribute (no dot in the string) but fails to identify the second one (data attribute has a dot)The text was updated successfully, but these errors were encountered: