jenkins-bot has submitted this change and it was merged.
Change subject: wikibits: Pass JSHint
......................................................................
wikibits: Pass JSHint
Change-Id: I95897e01b339c16abdd12190129d2b343be43d30
---
M .jshintignore
M skins/common/wikibits.js
2 files changed, 44 insertions(+), 37 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.jshintignore b/.jshintignore
index 64add55..2f3f2f8 100644
--- a/.jshintignore
+++ b/.jshintignore
@@ -26,7 +26,11 @@
resources/jquery.chosen/chosen.jquery.js
# legacy scripts
-skins/common/
+skins/common/IEFixes.js
+skins/common/ajax.js
+skins/common/config.js
+skins/common/protect.js
+skins/common/upload.js
# github.com/jshint/jshint/issues/729
tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js
diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js
index 93bf1ad..8c01ba3 100644
--- a/skins/common/wikibits.js
+++ b/skins/common/wikibits.js
@@ -46,16 +46,16 @@
// add any onload functions in this hook (please don't hard-code any events in
the xhtml source)
window.doneOnloadHook = undefined;
-if (!window.onloadFuncts) {
+if ( !window.onloadFuncts ) {
window.onloadFuncts = [];
}
window.addOnloadHook = function( hookFunct ) {
// Allows add-on scripts to add onload functions
- if( !doneOnloadHook ) {
- onloadFuncts[onloadFuncts.length] = hookFunct;
+ if( !window.doneOnloadHook ) {
+ window.onloadFuncts[window.onloadFuncts.length] = hookFunct;
} else {
- hookFunct(); // bug in MSIE script loading
+ hookFunct(); // bug in MSIE script loading
}
};
@@ -63,15 +63,15 @@
var uri = mw.config.get( 'wgScript' ) + '?title=' +
mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/javascript';
- return importScriptURI( uri );
+ return window.importScriptURI( uri );
};
window.loadedScripts = {}; // included-scripts tracker
window.importScriptURI = function( url ) {
- if ( loadedScripts[url] ) {
+ if ( window.loadedScripts[url] ) {
return null;
}
- loadedScripts[url] = true;
+ window.loadedScripts[url] = true;
var s = document.createElement( 'script' );
s.setAttribute( 'src', url );
s.setAttribute( 'type', 'text/javascript' );
@@ -80,7 +80,7 @@
};
window.importStylesheet = function( page ) {
- return importStylesheetURI( mw.config.get( 'wgScript' ) +
'?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
+ return window.importStylesheetURI( mw.config.get( 'wgScript' ) +
'?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
};
window.importStylesheetURI = function( url, media ) {
@@ -108,8 +108,10 @@
};
if ( mw.config.get( 'wgBreakFrames' ) ) {
- // Un-trap us from framesets
- if ( window.top != window ) {
+ // Note: In IE < 9 strict comparison to window is non-standard (the
standard didn't exist yet)
+ // it works only comparing to window.self or window.window
(http://stackoverflow.com/q/4850978/319266)
+ if ( window.top !== window.self ) {
+ // Un-trap us from framesets
window.top.location = window.location;
}
}
@@ -125,7 +127,7 @@
window.killEvt = function( evt ) {
evt = evt || window.event || window.Event; // W3C, IE, Netscape
- if ( typeof ( evt.preventDefault ) != 'undefined' ) {
+ if ( typeof evt.preventDefault !== 'undefined' ) {
evt.preventDefault(); // Don't follow the link
evt.stopPropagation();
} else {
@@ -142,7 +144,7 @@
text = text.replace( re, "\\'" );
re = new RegExp( "\\n", "g" );
text = text.replace( re, "\\n" );
- return escapeQuotesHTML( text );
+ return window.escapeQuotesHTML( text );
};
window.escapeQuotesHTML = function( text ) {
@@ -208,7 +210,7 @@
node = document.createElement( 'ul' );
var lastElementChild = null;
for ( var i = 0; i < root.childNodes.length; ++i ) { /* get
root.lastElementChild */
- if ( root.childNodes[i].nodeType == 1 ) {
+ if ( root.childNodes[i].nodeType === 1 ) {
lastElementChild = root.childNodes[i];
}
}
@@ -251,7 +253,7 @@
mw.util.updateTooltipAccessKeys( [link] );
}
- if ( nextnode && nextnode.parentNode == node ) {
+ if ( nextnode && nextnode.parentNode === node ) {
node.insertBefore( item, nextnode );
} else {
node.appendChild( item ); // IE compatibility (?)
@@ -261,10 +263,10 @@
};
window.getInnerText = function( el ) {
- if ( typeof el == 'string' ) {
+ if ( typeof el === 'string' ) {
return el;
}
- if ( typeof el == 'undefined' ) {
+ if ( typeof el === 'undefined' ) {
return el;
}
// Custom sort value through 'data-sort-value' attribute
@@ -286,7 +288,7 @@
for ( var i = 0; i < l; i++ ) {
switch ( cs[i].nodeType ) {
case 1: // ELEMENT_NODE
- str += getInnerText( cs[i] );
+ str += window.getInnerText( cs[i] );
break;
case 3: // TEXT_NODE
str += cs[i].nodeValue;
@@ -320,22 +322,22 @@
*/
window.getElementsByClassName = function( oElm, strTagName, oClassNames ) {
var arrReturnElements = [];
- if ( typeof( oElm.getElementsByClassName ) == 'function' ) {
+ if ( typeof oElm.getElementsByClassName === 'function' ) {
/* Use a native implementation where possible FF3, Saf3.2,
Opera 9.5 */
var arrNativeReturn = oElm.getElementsByClassName( oClassNames
);
- if ( strTagName == '*' ) {
+ if ( strTagName === '*' ) {
return arrNativeReturn;
}
for ( var h = 0; h < arrNativeReturn.length; h++ ) {
- if( arrNativeReturn[h].tagName.toLowerCase() ==
strTagName.toLowerCase() ) {
+ if( arrNativeReturn[h].tagName.toLowerCase() ===
strTagName.toLowerCase() ) {
arrReturnElements[arrReturnElements.length] =
arrNativeReturn[h];
}
}
return arrReturnElements;
}
- var arrElements = ( strTagName == '*' && oElm.all ) ? oElm.all :
oElm.getElementsByTagName( strTagName );
+ var arrElements = ( strTagName === '*' && oElm.all ) ? oElm.all :
oElm.getElementsByTagName( strTagName );
var arrRegExpClassNames = [];
- if( typeof oClassNames == 'object' ) {
+ if( typeof oClassNames === 'object' ) {
for( var i = 0; i < oClassNames.length; i++ ) {
arrRegExpClassNames[arrRegExpClassNames.length] =
new RegExp("(^|\\s)" +
oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)");
@@ -363,16 +365,17 @@
};
window.redirectToFragment = function( fragment ) {
- var match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
+ var webKitVersion,
+ match = navigator.userAgent.match(/AppleWebKit\/(\d+)/);
if ( match ) {
- var webKitVersion = parseInt( match[1] );
+ webKitVersion = parseInt( match[1], 10 );
if ( webKitVersion < 420 ) {
// Released Safari w/ WebKit 418.9.1 messes up horribly
// Nightlies of 420+ are ok
return;
}
}
- if ( window.location.hash == '' ) {
+ if ( !window.location.hash ) {
window.location.hash = fragment;
// Mozilla needs to wait until after load, otherwise the window
doesn't
@@ -382,11 +385,11 @@
// better twice than not at all, so make the fix hit future
versions as
// well.
if ( isGecko ) {
- addOnloadHook(function() {
- if ( window.location.hash == fragment ) {
+ $( function () {
+ if ( window.location.hash === fragment ) {
window.location.hash = fragment;
}
- });
+ } );
}
}
};
@@ -432,17 +435,17 @@
window.runOnloadHook = function() {
// don't run anything below this for non-dom browsers
- if ( doneOnloadHook || !( document.getElementById &&
document.getElementsByTagName ) ) {
+ if ( window.doneOnloadHook || !( document.getElementById &&
document.getElementsByTagName ) ) {
return;
}
// set this before running any hooks, since any errors below
// might cause the function to terminate prematurely
- doneOnloadHook = true;
+ window.doneOnloadHook = true;
// Run any added-on functions
- for ( var i = 0; i < onloadFuncts.length; i++ ) {
- onloadFuncts[i]();
+ for ( var i = 0; i < window.onloadFuncts.length; i++ ) {
+ window.onloadFuncts[i]();
}
};
@@ -462,7 +465,7 @@
};
window.hookEvent = function( hookName, hookFunct ) {
- addHandler( window, hookName, hookFunct );
+ window.addHandler( window, hookName, hookFunct );
};
/**
@@ -472,7 +475,7 @@
* @param handler callable Event handler callback
*/
window.addClickHandler = function( element, handler ) {
- addHandler( element, 'click', handler );
+ window.addHandler( element, 'click', handler );
};
/**
@@ -491,10 +494,10 @@
};
// note: all skins should call runOnloadHook() at the end of html output,
// so the below should be redundant. It's there just in case.
-hookEvent( 'load', runOnloadHook );
+window.hookEvent( 'load', window.runOnloadHook );
if ( isIE6 ) {
- importScriptURI( mw.config.get( 'stylepath' ) + '/common/IEFixes.js' );
+ window.importScriptURI( mw.config.get( 'stylepath' ) +
'/common/IEFixes.js' );
}
}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/60269
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I95897e01b339c16abdd12190129d2b343be43d30
Gerrit-PatchSet: 11
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Daniel Friesen <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Matmarex <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits