r74686 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74685‎ | r74686 | r74687 >
Date:19:15, 12 October 2010
Author:hartman
Status:ok (Comments)
Tags:
Comment:
* Test for the presence of addEventListener on the element on which we will actually use it.

Just in case someone messes with the normal environment.
Modified paths:
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/wikibits.js
@@ -1056,9 +1056,9 @@
10571057 * @param callable handler Event handler callback
10581058 */
10591059 window.addHandler = function( element, attach, handler ) {
1060 - if( window.addEventListener ) {
 1060+ if( element.addEventListener ) {
10611061 element.addEventListener( attach, handler, false );
1062 - } else if( window.attachEvent ) {
 1062+ } else if( element.attachEvent ) {
10631063 element.attachEvent( 'on' + attach, handler );
10641064 }
10651065 }

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:55, 12 January 2011

Was this a fix to an observed or imagined problem?

#Comment by Trevor Parscal (WMF) (talk | contribs)   18:28, 25 January 2011

This is at least not going to cause problems... It's probably solving for something sensible.

Status & tagging log