User "Krinkle" posted a comment on MediaWiki.r86625.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/86625#c16260
Commit summary:

(bug 27833) CollapsibleTabs doesn't collapse tabs due to JS errors
* Change remove() to detach() so .data() isn't lost
* Be more careful using the parent's .data() in addData()
* Change ele (which mysteriously isn't available in the closure) to this, 
they're the same anyway

Comment:

<pre>
+                       if ( typeof $settings != 'undefined' ) {
</pre>
I'm not sure this works as expected.  jQuery's <code>.data()</code> returns 
<code>null</code> when nothig could be found (atleast in the version we use in 
MediaWiki).

null has a type of "object" not "undefined".

To be future proof (since jQuery 1.5 returns undefined for unset data keys), 
you can do a loose comparison to null. For some reason doing a loose comparison 
to null will return true as well when the variable is undefined (this method is 
used in jQuery's internals as well).

<pre>
if ( varThatIsNullOrUndefined == null ) {
 alert(varThatIsNullOrUndefined == null);
}
<pre>

The only advantage to using typeof is to avoid a ReferenceError if the entire 
variable was undeclared, but that's not the case since the variable is declared 
right above it.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to