Cleanup strict build.

Former-commit-id: c34b2e7e2810e8bc35bde3e0f962d925b3f5ba1b
This commit is contained in:
John-David Dalton
2013-01-20 03:54:44 -08:00
parent 8b4d952929
commit 6c965e0223
3 changed files with 3273 additions and 8 deletions

View File

@@ -1153,13 +1153,12 @@
* @returns {String} Returns the modified source.
*/
function setUseStrictOption(source, value) {
// inject "use strict"
if (value) {
source = source.replace(/^[\s\S]*?function[^{]+{/, "$&\n 'use strict';");
}
// inject or remove the "use strict" directive
source = source.replace(/(^[\s\S]*?function[^{]+{)(?:\s*'use strict';)?/, '$1' + (value ? "\n 'use strict';" : ''));
// replace `strict` branch in `iteratorTemplate` with hard-coded option
source = source.replace(getIteratorTemplate(source), function(match) {
return match.replace(/(?: *\/\/.*\n)*(\s*)["'] *<%.+?strict.+/, value ? '$1"\'use strict\';\\n" +' : '');
return match.replace(/(template\()(?:\s*"'use strict.+)?/, '$1' + (value ? '\n "\'use strict\';\\n" +' : ''));
});
return source;

3269
doc/RADME.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -354,9 +354,6 @@
* @returns {String} Returns the interpolated text.
*/
var iteratorTemplate = template(
// conditional strict mode
"<% if (obj.useStrict) { %>'use strict';\n<% } %>" +
// the `iteratee` may be reassigned by the `top` snippet
'var index, iteratee = <%= firstArg %>, ' +
// assign the `result` variable an initial value