Extract doScrollCheck function into a variable #1192

Closed
wants to merge 1 commit into from

3 participants

@TheSpyder

I ship jQuery in a product I work on, and we recently discovered one of the places our product is used runs a JavaScript minification tool that breaks jQuery. It only renames the doScrollCheck call site, not the function declaration.

I do not have control over the minification tool so I was hoping this harmless change can be made in the core code instead.

This commit simply extracts the doScrollCheck function into a variable which allows the minification tool to pick up the function rename correctly.

@rwaldron
jQuery Foundation member

Thanks for the contribution!

There isn't really a bug here... The problem you've encountered is not a shortcoming of jQuery's, but of the minification tool. Named function expressions whose identifier is bound to the scope created by the function expression has existed in the language since 1999, please file a ticket with the minification tool's author(s) and link them back to this issue. I'm going to close this for now, but we have it here if we need to revisit at a later date.

@rwaldron rwaldron closed this Mar 4, 2013
@TheSpyder

I'm aware of how crazy it is that this minification tool can't handle the named function expression. However it isn't used anywhere else in jQuery, and the entire function was removed in version 2 (it's a fix specific to IE8 and below) so I was hoping it could be merged despite the fact that it isn't a jQuery bug.

I have no control over the deployment of the minification tool, in fact I'm not even sure if there is a tool I can log a bug against (it's embedded in IBM Connections).

@rwaldron
jQuery Foundation member

However it isn't used anywhere else in jQuery, and the entire function was removed in version 2 (it's a fix specific to IE8 and below)

Yes, I know... I removed it ;)

As for filing bugs, I'm going to ask that you at least try before assuming that jQuery wants to take the responsibility.

@gibson042
jQuery Foundation member

Immediately-invoked named function expressions are also used in callbacks.js. And not that it clinches the decision, but this particular pattern is not counted among the many perfectly valid expressions that nevertheless effect jshint warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment