-
Notifications
You must be signed in to change notification settings - Fork 621
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
Fix constructor #693
Fix constructor #693
Conversation
Codecov Report
@@ Coverage Diff @@
## master #693 +/- ##
==========================================
+ Coverage 66.03% 66.38% +0.35%
==========================================
Files 23 23
Lines 1316 1306 -10
==========================================
- Hits 869 867 -2
+ Misses 447 439 -8
Continue to review full report at Codecov.
|
@jshjohnson const elements = Array.from(
document.querySelectorAll(".your-class"),
element => new Choices(element)
); |
Nice - have updated |
Also need to update typings by removing brackets hack. |
@jshjohnson consider also #691 for 8.x 🙏 |
See here: 4435efc - let me know if this is wrong |
4435efc
to
6c745b4
Compare
Description
As highlighted by @tinovyatkin here, the ability to pass multiple elements to the Choices constructor and get multiple instances back was buggy at best. This PR removes that functionality so the Choices constructor will only ever return one instance and that instance will only be associated with one element. To achieve the same behaviour, you would need to do the following:
or even simpler:
I've also updated the constructor to throw an error if no valid element is passed or no valid element is found in the DOM. Previously this would have failed silently.
How Has This Been Tested?
Constructor tests have been added with this change.
Types of changes
Checklist: