r112015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112014‎ | r112015 | r112016 >
Date:13:41, 21 February 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
add test for where dismiss notification is an anchor tag

bug in previous code where onclick handlers of links broke the ability
to dismiss a notification.

this test provides coverage
fix applied to application.js and beta_
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/application.js (modified) (history)
  • /trunk/extensions/MobileFrontend/javascripts/beta_application.js (modified) (history)
  • /trunk/extensions/MobileFrontend/tests/js/fixtures.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/tests/js/fixtures.js
@@ -18,7 +18,7 @@
1919 ' </div>',
2020 ' <div id="zero-rated-banner">',
2121 ' banner',
22 - ' <button id="dismiss-notification">dismiss banner</button>',
 22+ ' <a href="#" id="dismiss-notification">dismiss banner</button>',
2323 ' </div>',
2424 ' <input type="text" id="search">',
2525 ' <button id="clearsearch">clear</button>',
Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js
@@ -105,11 +105,11 @@
106106 }
107107
108108 for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) {
109 - a[i].onclick = function() {
 109+ a[i].addEventListener( 'click', function() {
110110 if ( this.hash.indexOf( '#' ) == 0 ) {
111111 wm_reveal_for_hash( this.hash );
112112 }
113 - }
 113+ });
114114 }
115115
116116 // Try to scroll and hide URL bar
Index: trunk/extensions/MobileFrontend/javascripts/application.js
@@ -94,11 +94,11 @@
9595 }
9696
9797 for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) {
98 - a[i].onclick = function() {
 98+ a[i].addEventListener( 'click', function() {
9999 if ( this.hash.indexOf( '#' ) == 0 ) {
100100 wm_reveal_for_hash( this.hash );
101101 }
102 - }
 102+ });
103103 }
104104
105105 // Try to scroll and hide URL bar

Status & tagging log