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

Bug: Selector input.-username does not match <input className="field -username" /> #547

Closed
mik01aj opened this issue Aug 17, 2016 · 4 comments

Comments

@mik01aj
Copy link

mik01aj commented Aug 17, 2016

This element:

<input type="text" maxLength={32} value="" onChange={[Function]} placeholder="Dein Mitgliedsname" className="field -username" />

Is not matched by input.-username selector.

Btw, input.field.-username works, but the former should work too.

Using enzyme 2.3.0.

@ljharb
Copy link
Member

ljharb commented Aug 17, 2016

Can you link to the spec that shows where class names can start with a hyphen?

@mik01aj
Copy link
Author

mik01aj commented Aug 17, 2016

The CSS 2.1 spec says just that it shouldn't start with hyphen followed by a digit, but it's not the case here. And class names starting with hyphens are recommended for component variants in RSCSS.

@mik01aj
Copy link
Author

mik01aj commented Aug 19, 2016

I really needed this so I looked for a workaround and... attribute matching seems broken too. I have a dialog box that contains this: (as reported by wrapper.debug())

<Button action={[Function]} icon="facebook" className="-facebook" variant="filled" disabled={false}>
  <button style={[undefined]} className="Button -filled -facebook" disabled={false} onClick={[Function]}>
    <CommonIcon icon="facebook" className="rightIcon" orientation="right">
      <span className="CommonIcon -facebook rightIcon" dangerouslySetInnerHTML={{...}} />
    </CommonIcon>
  </button>
</Button>

And I tried to match the button with various selectors. .-facebook matched the button and the span inside the icon, but none of these...

button.-facebook
.Button.-facebook
.Button.-filled.-facebook
button[className="Button -filled -facebook"]
button[class="Button -filled -facebook"]
[className="Button -filled -facebook"]
[class="Button -filled -facebook"]
[className="-facebook"]
[class="-facebook"]

...matched anything. Now this seems a pretty serious bug. 🐞

Tried one more way: wrapper.find('Button').filter({icon: 'facebook'}) also doesn't return anything. find returns 3 buttons, but filter rejects all of them for some reason. FWIW, wrapper.find('Button').filterWhere(e => e.prop('icon') === 'facebook') works.

P.S. If it's not clear yet, I use the mount API.

@ljharb
Copy link
Member

ljharb commented Sep 26, 2017

Closed in #1086

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

2 participants