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

is ":not" selector not supported? #456

Closed
arch-mage opened this issue Jun 14, 2016 · 7 comments
Closed

is ":not" selector not supported? #456

arch-mage opened this issue Jun 14, 2016 · 7 comments

Comments

@arch-mage
Copy link

What I understand is that ":not" is a css selector to find an element without specified attribute.
So, with this component:

const Table = () => (
  <table>
    <thead>
      <tr>
        <th></th>
        <th></th>
      <tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row"></th>
        <td></td>
      <tr>
    </tbody>
  </table>
);

But why this is happening?

wrapper.find('th[scope="row"]').length // == 1
wrapper.find('th:not([scope="row"])').length // == 0 ?
@koba04
Copy link
Contributor

koba04 commented Jun 15, 2016

You can see enzyme is supporting CSS selectors in the following.

https://github.com/airbnb/enzyme/blob/master/docs/api/selector.md#1-a-valid-css-selector

@blainekasten
Copy link
Contributor

We'd gladly accept a PR if you were wanting to add support for the :not selector!

@AugustinLF
Copy link
Contributor

I'm giving it a try, I'll ley you know soon of my progress!

@arch-mage
Copy link
Author

I've sent the pull request. Can you check it?

@ljharb
Copy link
Member

ljharb commented Jul 6, 2018

This was added in #460.

@ljharb ljharb closed this as completed Jul 6, 2018
@akegan
Copy link

akegan commented Jan 18, 2019

Looks like the PR referenced above ended up getting closed rather than merged.

For anyone else ending up here from Google, here's the documentation for the implemented solution:
https://airbnb.io/enzyme/docs/api/ShallowWrapper/not.html

@ljharb
Copy link
Member

ljharb commented Jan 18, 2019

@akegan it ended up moving to #1086, and should be in all versions of enzyme 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants