-
-
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
Make hasClass work for mount
ed composite components
#677
Make hasClass work for mount
ed composite components
#677
Conversation
…assName, which allows ReactWrapper.hasClass to bypass the !isDOMComponent(inst) call
const wrapper = mount( | ||
<div className="foo bar baz some-long-string FoOo" />, | ||
); | ||
context('When using a DOM component', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb are you OK with using context
blocks here? I don't think we use them anywhere else, but it makes enough sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context
and describe
are identical - either is fine, but i have a light preference for describe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I know they're identical, it was just a question of preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, assuming we're OK with using that context
block in the test.
This (hopefully?) address the long running issue #134, where
wrapper.hasClass
always returns false onmount
ed composite components. The reason for the failure is the following block inMountedTraversal.js#instHasClassName
:Simply removing this block breaks many things, as the method is used internally in
MountedTraversal.js
. My naive solution is to split the method in two, so we retain the exportedinstHasClassName
function for use byReactWrapper.hasClass
, and extract a privatehasClassName
function for use internally inMountedTraversal.js
.From here we can remove the
!isDOMComponent
early exit code frominstHasClassName
, and instead add it tohasClassName
to maintain existing functionality.