Ensure the callback of _.filter can't modify the resulting value.

Former-commit-id: 6652dc5926390e8418b524c7ffd2347c2fa65c82
This commit is contained in:
John-David Dalton
2012-07-26 23:20:36 -07:00
parent 4ff12e0426
commit 943004844a
3 changed files with 59 additions and 30 deletions

View File

@@ -285,15 +285,25 @@
// minify properties
properties.forEach(function(property, index) {
var reBracketProp = RegExp("\\['" + property + '\\b', 'g'),
reDotProp = RegExp('\\.' + property + '\\b', 'g'),
rePropColon = RegExp('\\b' + property + ' *:', 'g');
// add quotes around properties in the inlined `_.sortBy` of the mobile
// build so Closure Compiler won't mung them
if (isSortBy && isInlined) {
modified = modified
.replace(RegExp('\\.' + property + '\\b', 'g'), "['" + minNames[index] + "']")
.replace(RegExp('\\b' + property + ' *:', 'g'), "'" + minNames[index] + "':");
.replace(reDotProp, "['" + minNames[index] + "']")
.replace(rePropColon, "'" + minNames[index] + "':");
}
else {
modified = modified
.replace(reBracketProp, "['" + minNames[index])
.replace(reDotProp, '.' + minNames[index])
.replace(rePropColon, minNames[index] + ':');
}
modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]);
});
// replace with modified snippet
source = source.replace(snippet, modified);
});