r106396 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106395‎ | r106396 | r106397 >
Date:23:51, 15 December 2011
Author:preilly
Status:ok
Tags:
Comment:
safer use of getElementById
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/beta_application.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js
@@ -121,7 +121,10 @@
122122 s.display = s.display == 'none' || ( i && !s.display ) ? 'inline-block' : 'none';
123123 }
124124 for ( var i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
125 - var s = document.getElementById( d[i] + section_id ).style;
126 - s.display = s.display == 'block' ? 'none' : 'block';
 125+ var e = document.getElementById( d[i] + section_id );
 126+
 127+ if ( e ) {
 128+ e.style.display = e.style.display == 'block' ? 'none' : 'block';
 129+ }
127130 }
128131 }
\ No newline at end of file

Status & tagging log