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

Fixed dataview filtering breaking, after compressing JS with e.g. Google Closure Compiler #243

Merged
merged 1 commit into from
Dec 8, 2011

Conversation

asavoy
Copy link
Contributor

@asavoy asavoy commented Dec 7, 2011

Background

We're using SlickGrid (it's awesome), and recently updated to latest. We found that after running our build scripts, which compress our JS files using Google Closure Compiler, our grids that used DataView filtering all broke.

Cause

The problem is with the general approach that SlickGrid.DataView's compileFilter() and compileFilterWithCaching() use; that is, using Function.toString() to fetch original source code for fnTemplate and the user's filter function, to generate a new function.

The code relies on carefully named variables to act as targets for later string replacement. These will be shortened/changed by compressors, so the behavior ends up broken.

(The code also makes some pretty strong expectations about the style/structure of the user's filter function, which causes other issues... I will elaborate in a separate issue)

Fix

To fix, I rewrote the function templates as strings, since it's only there so that the function body can be retrieved via Function.toString(). This prevents them from being modified by a JS compressor. Unfortunately, the readability is penalised a little bit.

Furthermore, there isn't any workaround offered by Google Closure Compiler; there is no way to ignore or "not-compress" the code, whether at the function level or at the file level.

I hope this saves someone else hours of debugging...

…gle Closure Compiler

compileFilter(): Rewrote function templates to survive JS compression whilst preserving original behavior
@mleibman
Copy link
Owner

mleibman commented Dec 8, 2011

Thanks! I haven't considered the minification.

mleibman added a commit that referenced this pull request Dec 8, 2011
Fixed dataview filtering breaking, after compressing JS with e.g. Google Closure Compiler
@mleibman mleibman merged commit 48cdfad into mleibman:master Dec 8, 2011
@slubowsky
Copy link

Seems like same problem occurs with formatters...

vlsi pushed a commit to vlsi/SlickGrid that referenced this pull request Jul 19, 2018
…-on-edit

bugfix(editor): add a flag to suppress active cell changed on edit mleibman#242
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.

3 participants