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

Cascades in one closure get same varname #190

Closed
akx opened this issue Nov 13, 2012 · 1 comment
Closed

Cascades in one closure get same varname #190

akx opened this issue Nov 13, 2012 · 1 comment
Labels

Comments

@akx
Copy link

akx commented Nov 13, 2012

$('#something')
  &click !-> blah(&attr("foo"))

$('#somethingelse')
  &click !-> blah(&attr("bar"))

compiles to

var x$;
x$ = $('#something');
x$.click(function(){
  blah(x$.attr("foo"));
});
x$ = $('#somethingelse');
x$.click(function(){
  blah(x$.attr("bar"));
});

which causes problems with the first click handler's x$ referring to the second one due to lexical scope.

I know this could be easily circumvented with let but I still think this is counter-intuitive behavior.

Feel free to close if I'm wrong :)

@satyr
Copy link
Owner

satyr commented Nov 13, 2012

You're right. Apparently it shouldn't reuse the same variable.

@satyr satyr closed this as completed in 3a85ac1 Nov 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants