8000 Fix `_.sortBy` in the mobile build. · lodash/lodash@57ae192 · GitHub
[go: up one dir, main page]

Skip to content

Commit 57ae192

Browse files
committed
Fix _.sortBy in the mobile build.
Former-commit-id: 0af3778e89e61effbe60347d6f0bcb33d8c37a2e
1 parent d493185 commit 57ae192

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

build/pre-compile.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,18 @@
257257
return;
258258
}
259259
snippets.forEach(function(snippet) {
260-
var result = snippet;
260+
var result = snippet,
261+
isSortBy = /var sortBy\b/.test(result);
261262

262263
// minify properties
263264
properties.forEach(function(property, index) {
265+
// add quotes around properties in the inlined method of the mobile build
266+
// so Closure Compiler won't mung them
267+
if (isSortBy) {
268+
result = result
269+
.replace(RegExp('\\.' + property + '\\b', 'g'), "['" + minNames[index] + "']")
270+
.replace(RegExp('\\b' + property + ' *:', 'g'), "'" + minNames[index] + "':");
271+
}
264272
result = result.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]);
265273
});
266274
// replace with modified snippet

0 commit comments

Comments
 (0)
0