-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Reduce method complexity of setParameters() #1634
Conversation
Created two functions: * setDefaultInputValidators(): to assign default input validators * validateCustomTargetElement(): to check if the target element is a valid one Also: * Moved warning message to a constant outside of function * Code clean-up
Codeclimate integration reports only 1 issue fixed ("Function setParameters has 34 lines of code (exceeds 25 allowed). Consider refactoring."). I'm checking about method complexity. |
Pull Request Test Coverage Report for Build 5068
💛 - Coveralls |
The previous logic was redundant because was returning always true
In 8e989d2 I removed the if statement at the end of the sweetalert2/src/utils/setParameters.js Lines 54 to 56 in 801edf0
always returned Replacing the right side of the OR with a more correct:
makes 11 test fail: ✗ toast aria attributes I can analyze why the above fails (likely cause is that the |
cf788a8
to
ba73581
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.
I can analyze why the above fails (likely cause is that the dom is not updated unless the target element is different), but before doing so, do you agree with my analysis that that condition is always true? Or is there some obscure use case that I cannot think of that needs that check?
This is the leftover from the previous versions when we were reusing the same DOM node for all popups. Now we're creating the new DOM node (.swal2-container
) for each popup.
Thank you @gverni! I reverted the |
🎉 This PR is included in version 8.13.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Created two functions:
setDefaultInputValidators()
: to assign default input validatorsvalidateCustomTargetElement()
: to check if the target element is a valid oneAlso:
Fix #1490