mediawiki.action.view.dblClickEdit: Do not call click on undefined
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 20 Nov 2014 12:59:16 +0000 (13:59 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 21 Nov 2014 21:58:39 +0000 (21:58 +0000)
Not all pages in a MediaWiki installation have an edit link. For
example the pages in Wikidata do not have it.

Bug: 57713
Change-Id: I842c1224d15887d59eab73f2b222c232a05c0bd9

resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js

index 3c22851..2be29f0 100644 (file)
@@ -8,7 +8,11 @@
                        if ( parseInt( mw.user.options.get( 'editondblclick' ), 10 ) ) {
                                e.preventDefault();
                                // Trigger native HTMLElement click instead of opening URL (bug 43052)
-                               $( '#ca-edit a' ).get( 0 ).click();
+                               var $a = $( '#ca-edit a' );
+                               // Not every page has an edit link (bug 57713)
+                               if ( $a.length ) {
+                                       $a.get( 0 ).click();
+                               }
                        }
                } );
        } );