From 57ae1925b14ef5be73b8247e6f49fa64387ab075 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 8 Jul 2012 03:30:16 -0400 Subject: [PATCH] Fix `_.sortBy` in the mobile build. Former-commit-id: 0af3778e89e61effbe60347d6f0bcb33d8c37a2e --- build/pre-compile.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/pre-compile.js b/build/pre-compile.js index 6c897428b..c8e3ade81 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -257,10 +257,18 @@ return; } snippets.forEach(function(snippet) { - var result = snippet; + var result = snippet, + isSortBy = /var sortBy\b/.test(result); // minify properties properties.forEach(function(property, index) { + // add quotes around properties in the inlined method of the mobile build + // so Closure Compiler won't mung them + if (isSortBy) { + result = result + .replace(RegExp('\\.' + property + '\\b', 'g'), "['" + minNames[index] + "']") + .replace(RegExp('\\b' + property + ' *:', 'g'), "'" + minNames[index] + "':"); + } result = result.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]); }); // replace with modified snippet