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

Ref incorrectly set for HTMLElement #2253

Closed
IamTheHttp opened this issue Oct 3, 2019 · 0 comments · Fixed by #2259
Closed

Ref incorrectly set for HTMLElement #2253

IamTheHttp opened this issue Oct 3, 2019 · 0 comments · Fixed by #2259
Assignees

Comments

@IamTheHttp
Copy link

Current behavior

In react,
Refs for node elements are the underlying DOM HTMLElement,
Refs for Components are the Component instance.

When using Enzyme and mounting an html node element, the ref is not an HTMLElement

Expected behavior

The expected behaviour is to be on par with React, it shouldn't behave differently, the ref should be the element itself.

Your environment

Node 12.4
Mac OSx Sierra

API

  • mount

Version

library version
enzyme 3.8.0
react 16.8.2
react-dom 16.8.2
react-test-renderer
adapter (below) 1.9.1

Adapter

  • enzyme-adapter-react-16
    mount(<div  
      ref={(el) => {  
        console.log(el);  
        el.removeEventListener('click'); // exception, not a function  
      }}  
    >  
    </div>);  
ljharb added a commit to ljharb/enzyme that referenced this issue Oct 10, 2019
…the root’s `ref` prop gets attached to the actual root

Fixes enzymejs#2253.
ljharb added a commit that referenced this issue Oct 10, 2019
…the root’s `ref` prop gets attached to the actual root

Fixes #2253.
@ljharb ljharb self-assigned this Oct 10, 2019
@ljharb ljharb closed this as completed in 7836e57 Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants