Skip to content

Add empty element check in case element was filtered by toggleDisabled #670

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

Merged
merged 2 commits into from
Apr 18, 2018

Conversation

BrianRosamilia
Copy link
Contributor

@BrianRosamilia BrianRosamilia commented Jan 4, 2018

When using the toggleDisabled plugin, you will get an exception without the check I've added if you try filtering out a form

https://github.com/BrianRosamilia/jQuery-Form-Validator/blob/master/src/modules/toggleDisabled.js#L34-L91

On line 34, the plugin is filtering out elements and on line 91 you're calling validateOnEvent. this will actually be an empty jQuery object if there was a form element that was filtered by toggleDisabled. This causes an exception when you call validateOnEvent (due to the assumed existence of this[0])

I don't have a POC but hopefully this is an uncontroversial change since this[0]. without a length === 0 check can always potentially cause an exception. Thanks! 👍

@victorjonsson victorjonsson merged commit 43369d5 into victorjonsson:master Apr 18, 2018
@victorjonsson
Copy link
Owner

👍

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

Successfully merging this pull request may close these issues.

2 participants