https://bugzilla.wikimedia.org/show_bug.cgi?id=63728
Bug ID: 63728
Summary: "var TEST = true" in (User/MediaWiki) .js pages should
not create global variables
Product: MediaWiki
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: JavaScript
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected],
[email protected]
Blocks: 700, 9968
Web browser: ---
Mobile Platform: ---
If a user uses something like
> window.windowDotSomething = true;
> justSomething = true;
to declare a few variables they will be global variables, and if the user uses
> var varSomething = true;
in a ResourceLoader-enabled gadget or in their new global.js provided by the
GlobalCssJs extension, this will create a local variable (they are inside of a
mw.loader.implement wrapper). This is the expected behavior.
However
> var varSomething = true;
results in a *global* variable if inserted in user subpages like
[[Special:MyPage/common.js]] or [[MediaWiki:Common.js]]:
> window.varSomething
true
Using "var" should not create a global variable in any case, and users should
not rely in the current behavior when writing their scripts, because this
usually causes bugs when porting user scripts to gadgets, due to the need to
replace lots of "var example"s with explicitly declared globals like
"window.example".
TLDR: drop support for executing page.js scripts in the global scope.
--
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l