{"action":"closed","number":243,"pull_request":{"review_comments":0,"created_at":"2011-12-07T08:20:27Z","state":"closed","updated_at":"2011-12-08T23:57:21Z","patch_url":"https://github.com/mleibman/SlickGrid/pull/243.patch","changed_files":1,"_links":{"review_comments":{"href":"https://api.github.com/repos/mleibman/SlickGrid/pulls/243/comments"},"comments":{"href":"https://api.github.com/repos/mleibman/SlickGrid/issues/243/comments"},"html":{"href":"https://github.com/mleibman/SlickGrid/pull/243"},"self":{"href":"https://api.github.com/repos/mleibman/SlickGrid/pulls/243"}},"issue_url":"https://github.com/mleibman/SlickGrid/issues/243","user":{"gravatar_id":"d01521f64cd431559c64df94fdda944e","id":235466,"url":"https://api.github.com/users/asavoy","avatar_url":"https://secure.gravatar.com/avatar/d01521f64cd431559c64df94fdda944e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"asavoy"},"comments":1,"merged":true,"body":"\r\n### Background\r\n\r\nWe'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.\r\n\r\n### Cause\r\n\r\nThe 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. \r\n\r\nThe 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.\r\n\r\n(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)\r\n\r\n### Fix\r\n\r\nTo 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.\r\n\r\nFurthermore, 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.\r\n\r\n\r\nI hope this saves someone else hours of debugging...\r\n\r\n","deletions":28,"mergeable":null,"commits":1,"id":566667,"additions":32,"base":{"repo":{"pushed_at":"2011-12-08T23:57:21Z","created_at":"2009-12-17T18:27:47Z","updated_at":"2011-12-08T23:57:21Z","private":false,"clone_url":"https://github.com/mleibman/SlickGrid.git","name":"SlickGrid","svn_url":"https://svn.github.com/mleibman/SlickGrid","master_branch":"master","watchers":1203,"language":"JavaScript","forks":182,"owner":{"gravatar_id":"a36c0ac449099295cb1a09bc98eb1ae2","id":168725,"url":"https://api.github.com/users/mleibman","avatar_url":"https://secure.gravatar.com/avatar/a36c0ac449099295cb1a09bc98eb1ae2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mleibman"},"id":440826,"homepage":"http://wiki.github.com/mleibman/SlickGrid","description":"A lightning fast JavaScript grid/spreadsheet","git_url":"git://github.com/mleibman/SlickGrid.git","html_url":"https://github.com/mleibman/SlickGrid","open_issues":73,"size":408,"url":"https://api.github.com/repos/mleibman/SlickGrid","fork":false,"ssh_url":"git@github.com:mleibman/SlickGrid.git"},"user":{"gravatar_id":"a36c0ac449099295cb1a09bc98eb1ae2","id":168725,"url":"https://api.github.com/users/mleibman","avatar_url":"https://secure.gravatar.com/avatar/a36c0ac449099295cb1a09bc98eb1ae2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mleibman"},"sha":"59e6a600cb679aa2c405a8723db6861e5eec5776","ref":"master","label":"mleibman:master"},"number":243,"merged_by":{"gravatar_id":"a36c0ac449099295cb1a09bc98eb1ae2","id":168725,"url":"https://api.github.com/users/mleibman","avatar_url":"https://secure.gravatar.com/avatar/a36c0ac449099295cb1a09bc98eb1ae2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mleibman"},"head":{"repo":{"pushed_at":"2011-12-07T06:59:49Z","created_at":"2011-12-07T06:27:05Z","updated_at":"2011-12-07T06:59:50Z","private":false,"clone_url":"https://github.com/asavoy/SlickGrid.git","name":"SlickGrid","svn_url":"https://svn.github.com/asavoy/SlickGrid","master_branch":"master","watchers":1,"language":"JavaScript","forks":0,"owner":{"gravatar_id":"d01521f64cd431559c64df94fdda944e","id":235466,"url":"https://api.github.com/users/asavoy","avatar_url":"https://secure.gravatar.com/avatar/d01521f64cd431559c64df94fdda944e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"asavoy"},"id":2930684,"homepage":"http://wiki.github.com/mleibman/SlickGrid","description":"A lightning fast JavaScript grid/spreadsheet","git_url":"git://github.com/asavoy/SlickGrid.git","html_url":"https://github.com/asavoy/SlickGrid","open_issues":0,"size":124,"url":"https://api.github.com/repos/asavoy/SlickGrid","fork":true,"ssh_url":"git@github.com:asavoy/SlickGrid.git"},"user":{"gravatar_id":"d01521f64cd431559c64df94fdda944e","id":235466,"url":"https://api.github.com/users/asavoy","avatar_url":"https://secure.gravatar.com/avatar/d01521f64cd431559c64df94fdda944e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"asavoy"},"sha":"0cff6d873c948bb4f1f744d3ac31811086a35201","ref":"fix-filter-when-compressed","label":"asavoy:fix-filter-when-compressed"},"title":"Fixed dataview filtering breaking, after compressing JS with e.g. Google Closure Compiler","html_url":"https://github.com/mleibman/SlickGrid/pull/243","closed_at":"2011-12-08T23:57:21Z","url":"https://api.github.com/repos/mleibman/SlickGrid/pulls/243","diff_url":"https://github.com/mleibman/SlickGrid/pull/243.diff","merged_at":"2011-12-08T23:57:21Z"}}