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

find with href attribute of full URL is rejected for being complex #283

Closed
vegetabill opened this issue Mar 25, 2016 · 8 comments
Closed
Labels

Comments

@vegetabill
Copy link

I may have missed an explanation in #70 but I expected this selector to work:

.find('a[href='http://example.com/xyz']')

But instead it complains:
TypeError: Enzyme received a complex CSS selector ('a[href='http://example.com/xyz']') that it does not currently support

If I remove the domain name from URL and make it relative, it works:

.find('a[href='/xyz']')

It gives no error and works as expected.

@lelandrichardson
Copy link
Collaborator

Hmm. This is an unfortunate side effect of the shitty CSS parsing we are doing.

An alternative for you right now is to do: .find({ href: url }) instead of the stringified CSS selector.

@andrewmclagan
Copy link

also experiencing this with a selector as follows:

find('img[src="http://image.com/image.jpg"]')

@aweary
Copy link
Collaborator

aweary commented Apr 27, 2016

@lelandrichardson is there a long-term plan for how you guys want to approach CSS selector parsing? Maybe something that returns an AST for selectors?

@stevenmusumeche
Copy link

An update on this?

@aweary
Copy link
Collaborator

aweary commented Feb 7, 2017

@stevenmusumeche our CSS parsing is still not great, we're tracking it and hope to implement an actual CSS parser soon. Until then I'd recommend the workaround that @lelandrichardson mentioned:

An alternative for you right now is to do: .find({ href: url }) instead of the stringified CSS selector.

@LazerJesus
Copy link

+1

@aweary
Copy link
Collaborator

aweary commented Aug 25, 2017

This will be resolved by #1086

@ljharb
Copy link
Member

ljharb commented Sep 26, 2017

Closed in #1086

@ljharb ljharb closed this as completed Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants