Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit839e62b

Browse files

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎lib/rewire.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ function internalRewire(parentModulePath, targetPath) {
3636
// We prepend a list of all globals declared with var so they can be overridden (without changing original globals)
3737
prelude=getImportGlobalsSrc();
3838

39+
// The module src is wrapped inside a self-executing function.
40+
// This is necessary to separate the module src from the preceding importGlobalsSrc,
41+
// because the module src can be in strict mode.
42+
// In strict mode eval() can only declare vars in the current scope. In this case our setters
43+
// and getters won't work.
44+
//@see http://whereswalden.com/2011/01/10/new-es5-strict-mode-support-new-vars-created-by-strict-mode-eval-code-are-local-to-that-code-only/
45+
// It also circumvents a problem with identical global variables and function declarations
46+
//@see https://github.com/jhnns/rewire/issues/56
47+
prelude+="(function () { ";
48+
3949
// We append our special setter and getter.
4050
appendix="\n"+getDefinePropertySrc();
51+
// End of self-executing function
52+
appendix+="})();";
4153

4254
// Check if the module uses the strict mode.
4355
// If so we must ensure that "use strict"; stays at the beginning of the module.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp