Page MenuHomePhabricator

Adding some var declarations to MediaWiki's JavaScript.
Closed, ResolvedPublic

Description

Author: nickpj

Description:
Adding some var declarations to MediaWiki's JavaScript for maximum correctness
for issues reported by "FireBug" (a firefox JavaScript correctness checking
extension). Will attach a diff with these shortly.

Also the place in the default [[MediaWiki:Monobook.js]] where the tooltip /

access key JS is declared should be updated like so:

/* tooltips and access keys */
  • ta = new Object();

+ var ta = new Object();

ta['pt-userpage'] = new Array('.','My user page');
ta['pt-anonuserpage'] = new Array('.','The user page for the ip you\'re

editing as');


Version: 1.7.x
Severity: minor

Details

Reference
bz6565

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:19 PM
bzimport set Reference to bz6565.
bzimport added a subscriber: Unknown Object (MLST).

nickpj wrote:

Wikibits var declarations

Attaching diff with var declarations as per above.

Attached:

Er, what's wrong here? These are global declarations.

nickpj wrote:

Omitting the var will still work; but from my understanding using var is
recommended.

Quoting from the Core JavaScript 1.5 Reference (
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Statements:var
) :
"The scope of a variable is the current function or, for variables declared
outside a function, the current application. Using var outside a function is
optional; assigning a value to an undeclared variable implicitly declares it as
a global variable. However, it is recommended to always use var."