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;