Skip to content

support :focus pseudo selector in mount#1965

Merged
ljharb merged 1 commit into
enzymejs:masterfrom
chenesan:focus-pseudo-selector
Jan 8, 2019
Merged

support :focus pseudo selector in mount#1965
ljharb merged 1 commit into
enzymejs:masterfrom
chenesan:focus-pseudo-selector

Conversation

@chenesan

@chenesan chenesan commented Jan 5, 2019

Copy link
Copy Markdown
Contributor

Fixes #1709 by compare document.activeElement and host DOM node of rst node. Work with DOMElement and component element.

Note that this only works with mount, not works with shallow. Also it won't work with simulate:

const wrapper = mount(<input type="text" />)
wrapper.simulate('focus')
// will print false
console.log(wrapper.is(":focus"))

I've tested this with jsdom@6 (in test suite), 13 and 12.


});

it('focus pseudo works on functional component in mount', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that stateless component not work in [email protected] so removed it here and rewrite other tests with class component

Comment thread packages/enzyme-test-suite/test/selector-spec.jsx Outdated
Comment thread packages/enzyme-test-suite/test/selector-spec.jsx
Comment thread packages/enzyme-test-suite/test/selector-spec.jsx
Comment thread packages/enzyme-test-suite/test/selector-spec.jsx
Comment thread packages/enzyme/src/selectors.js Outdated
Comment thread packages/enzyme/src/selectors.js Outdated
Comment thread packages/enzyme/src/selectors.js Outdated
Comment thread packages/enzyme/src/selectors.js Outdated
Comment thread packages/enzyme/src/selectors.js Outdated
Comment thread packages/enzyme/src/selectors.js Outdated
@ljharb
ljharb force-pushed the focus-pseudo-selector branch from bc74714 to d66104f Compare January 8, 2019 08:32
@ljharb
ljharb merged commit d66104f into enzymejs:master Jan 8, 2019
@malouro

malouro commented Jan 24, 2019

Copy link
Copy Markdown

This hasn't been released yet, right? Curious to know when the next release might be. Thanks 🙂

@ljharb

ljharb commented Feb 24, 2019

Copy link
Copy Markdown
Member

@malouro it has been released now, in v3.9.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants