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
Support customElements #320
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
6ed458c
to
b658abe
Compare
b658abe
to
ae45d01
Compare
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.
Awesome. Thanks. Just a few comments/suggestions.
src/__tests__/helpers/utils.js
Outdated
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} | ||
} |
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.
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
.
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.
yea good idea! fixing...
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
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.
Super duper. Thank you!
🎉 This PR is included in version 11.3.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
@all-contributors please add @hontas for code and tests |
I've put up a pull request to add @hontas! 🎉 |
Thank you for your super-duper quick feedback and merge! :) |
What: fixes #319
Why: in order to support custom elements
How: modify the
currentElement
helper to return nestedactiveElement
inside shadow DOMChecklist:
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 :)