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

Support customElements #320

Merged

Conversation

hontas
Copy link
Contributor

@hontas hontas commented Jun 8, 2020

What: fixes #319

Why: in order to support custom elements

How: modify the currentElement helper to return nested activeElement inside shadow DOM

Checklist:

  • Documentation N/A
  • Tests
  • Typings - I'm not familiar with TS - not sure if I need to do anything here
  • Ready to be merged

There were more changes required in the testing helpers than in the actual library - I'm open to suggestions on how to improve my suggested solution :)

@hontas hontas changed the title type: support customElements Support customElements Jun 8, 2020
@codecov
Copy link

codecov bot commented Jun 8, 2020

Codecov Report

Merging #320 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #320      +/-   ##
==========================================
+ Coverage   99.31%   99.32%   +0.01%     
==========================================
  Files           2        2              
  Lines         293      298       +5     
  Branches       74       76       +2     
==========================================
+ Hits          291      296       +5     
  Misses          2        2              
Impacted Files Coverage Δ
src/type.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c11411...38a04fc. Read the comment docs.

@hontas hontas force-pushed the pr/support-custom-elements branch 3 times, most recently from 6ed458c to b658abe Compare June 8, 2020 14:15
@hontas hontas force-pushed the pr/support-custom-elements branch from b658abe to ae45d01 Compare June 8, 2020 14:18
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Awesome. Thanks. Just a few comments/suggestions.

Comment on lines 40 to 55
function setup(ui, {shadowRootSelector} = {}) {
let hostElement
let {
container: {firstChild: element},
} = render(ui)

if (shadowRootSelector) {
hostElement = element
element = element.shadowRoot.querySelector(shadowRootSelector)
}

element.previousTestData = getTestData(element)

const {getEventCalls, clearEventCalls} = addListeners(element)
return {element, getEventCalls, clearEventCalls}
return {element, hostElement, getEventCalls, clearEventCalls}
}
Copy link
Member

Choose a reason for hiding this comment

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

Rather than complicating the setup function (especially for what will likely be only a very small number of tests that need it), let's just not use the setup function in the test and instead use addListeners.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea good idea! fixing...

src/type.js Outdated Show resolved Hide resolved
hontas and others added 3 commits June 8, 2020 19:12
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Super duper. Thank you!

@kentcdodds kentcdodds merged commit a55a657 into testing-library:master Jun 8, 2020
@kentcdodds
Copy link
Member

🎉 This PR is included in version 11.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kentcdodds
Copy link
Member

@all-contributors please add @hontas for code and tests

@allcontributors
Copy link
Contributor

@kentcdodds

I've put up a pull request to add @hontas! 🎉

@hontas
Copy link
Contributor Author

hontas commented Jun 8, 2020

Thank you for your super-duper quick feedback and merge! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support firing events inside of custom element shadow DOM
2 participants