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

Emit scrambles variables if passing 4+ parameters with a callback, in IE9. #112

Open
mGuv opened this issue Jun 2, 2015 · 1 comment
Open

Comments

@mGuv
Copy link

mGuv commented Jun 2, 2015

Odd title but this is a very specific issue, it seems. I've only seen this happen in Internet Explorer 9.

If you emit four or more variables with the last parameter being a function. When the function is passed through, "asyncAngularify", it also causes the third parameter (index 2) to change in to the resulting function.

E.g.

angularSocket.emit("MyEvent", dataA, dataB, dataC, someCallback);

Will get passed to socket as:

emit("MyEvent", dataA, wrappedCallback, dataC, wrappedCallback);

I believe this is a crazy issue to do with IE9s interpretation of the function. The function is defined as:

emit: function (eventName, data, callback)

Yet these parameters are never used, however, it does do:

var callback = arguments[lastIndex];

The key part here being that callback has been declared twice. Once, as parameter 3 of the arguments array (function definition) and now once as the final parameter of the arguments. So when:

callback = asyncAngularify(socket, callback);

happens, I believe it overwrites both arguments[2] and arguments[length - 1]

The fix for me so far is just to remove the variables in the function definition. Other methods would be to rename the parameters so there are no conflicting ones.

@mGuv
Copy link
Author

mGuv commented Jun 2, 2015

Just noticed it was spotted before:

#54

However, IE9 doesn't support use strict.

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

No branches or pull requests

1 participant