Skip to content

Ref incorrectly set for HTMLElement #2253

@IamTheHttp

Description

@IamTheHttp

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>);  

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions