mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
Provide filename to isolation function.
This commit is contained in:
parent
8bf0e7c2aa
commit
71dfced06d
1 changed files with 4 additions and 3 deletions
|
@ -179,7 +179,8 @@ function _handle(req, res, jsFilename, jsFiles) {
|
|||
|
||||
if(type == "JS")
|
||||
{
|
||||
embeds[filename] = compressJS([isolateJS(data)]);
|
||||
var shortFilename = filename.replace(/^..\/static\/js\//, '');
|
||||
embeds[filename] = compressJS([isolateJS(data, shortFilename)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -297,14 +298,14 @@ function tarCode(filesInOrder, files, write) {
|
|||
for(var i = 0, ii = filesInOrder.length; i < filesInOrder.length; i++) {
|
||||
var filename = filesInOrder[i];
|
||||
write("\n\n\n/*** File: static/js/" + filename + " ***/\n\n\n");
|
||||
write(isolateJS(files[filename]));
|
||||
write(isolateJS(files[filename], filename));
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap the following code in a self executing function and assign exports to
|
||||
// global. This is a first step towards removing symbols from the global scope.
|
||||
// exports is global and require is a function that returns global.
|
||||
function isolateJS(code) {
|
||||
function isolateJS(code, filename) {
|
||||
return '(function (exports, require) {'
|
||||
+ code + '\n'
|
||||
+ '}(function () {return this}(), (function (path) {return (function () {return this}())})));\n';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue