"Santhosh.thottingal" changed the status of MediaWiki.r106706 to "resolved"
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/106706
Old status: new
> New status: resolved
Commit summary for MediaWiki.r106706:
[WebFonts] Code quality & clean up
* Various good practices, white space conventions (Thanks JSLint)
* Such as:
-- JavaScript does not have block scope! Removed var statements from loops, and
put them outside the loop for clarity
-- Optimize a few loops (swapped a 'for in' loop for a 'for i < length' loop,
since it was an array, and improved the existing one by caching the length
property since otherwise the length property would be accessed every iteration
- also prevents infinite loops in some situations)
-- Combining var statements. Ideally every function only needs 1 var statement
(since there is only function scope and everything is hoisted internally
anyway), but no time to go through and restructure them all right now, did most
of them.
-- Improve function documentation ('@param config The webfont configuration.'
-> '@param fonts {Array} List of fonts to be provided as a menu option.')
-- Removed unused variables (such as 'languages' in
loadFontsForFontFamilyStyle, added in r100677)
-- Using strict comparison to false values (match(..) === null), both for speed
gain and improve readability as loose comparison is ambiguous in JavaScript
(val == null also returns true for undefined instead of null)
-- Using direct property access and strict comparison instead of an ' in '
lookup
-- Rename a variable called 'config' to 'fonts' (array) to avoid confusion with
another variable that is a plain object also called 'config'
-- Make 'mw' a local variable by passing it through the IIFE closure from the
global scope (for faster lookups in the context object)
-- Using the "||" operator in a variable assignment as "var = foo || bar"
instead of "var = foo ? foo : bar". In JavaScript comparison operators do not
return boolean, instead they return the last compared value. (which in an
if-statement is then type-coerced to a boolean)
-- Using mw.util.addCSS instead of creating a new <style> element locally.
-- Trailing whitespace
-- Redundant spaces (e.g. double space where single space was intended)
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview