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

Fixes an issue of args === undefined and script terminates #3851

Merged

Conversation

yallups
Copy link
Contributor

@yallups yallups commented Oct 19, 2015

I am returning false on select2:opening and I get this error for args being undefined. it terminates execution and breaks other things.

in this patch the functionality remains without breaking execution.

I tried being explicit in the code convention but this could also be a small footprint with
A:

args || (args = {});

B:

args === undefined && (args = {});

@yallups
Copy link
Contributor Author

yallups commented Oct 19, 2015

I have this work around at the moment
https://gist.github.com/yallups/ea797dceaa2c18898554

@yallups yallups changed the title Fixes and issue where If args are not present script terminates Fixes an issue of args === undefined and script terminates Oct 20, 2015
@yallups
Copy link
Contributor Author

yallups commented Oct 20, 2015

Just found the issue that this fixes. #3431
I know that @kevin-brown wants to make sure to always pass an empty object as an argument but I have a feeling that this will keep coming back. If the function is dependent on having an object with a property then we should make sure we have one and it shouldn't be the responsibility of the caller. (IMO ;))

@kevin-brown
Copy link
Member

I tried being explicit in the code convention

I'd much rather have the code be explicit in this case, so the current way is fine.

I know that @kevin-brown wants to make sure to always pass an empty object as an argument but I have a feeling that this will keep coming back.

The main reason for framing this as a "let's fix the missing object" issue instead of a "let's prevent this going further" was because I'd rather favor explicitly passing in no extra parameters when raising an event than having that handled implicitly. That's within the core codebase though, which is something we control, and it's not something we can expect for third-party plugins and adapters.

So yeah, this PR seems reasonable.

kevin-brown added a commit that referenced this pull request Oct 20, 2015
Fixes an issue of args === undefined and script terminates
@kevin-brown kevin-brown merged commit 6be96cf into select2:master Oct 20, 2015
@yallups
Copy link
Contributor Author

yallups commented Oct 21, 2015

Thanks for the merge!
I see your point about being explicit in the method call though.

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.

None yet

2 participants