Merge "tests: group structures tests in their own directory"
[lhc/web/wiklou.git] / resources / mediawiki.action / mediawiki.action.view.rightClickEdit.js
index d02d432..0e85fd9 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * JavaScript to enable right click edit functionality.
  * When the user right-clicks in a heading, it will open the
  * edit screen.
@@ -8,23 +8,19 @@ jQuery( function ( $ ) {
        // Don't use the ":has:(.editsection a)" selector because it performs very bad.
        // http://jsperf.com/jq-1-7-2-vs-jq-1-8-1-performance-of-mw-has/2
        $( document ).on( 'contextmenu', 'h1, h2, h3, h4, h5, h6', function ( e ) {
-               var $edit, href;
-
-               $edit = $( this ).find( '.editsection a' );
+               var $edit = $( this ).find( '.mw-editsection a, .editsection a' );
                if ( !$edit.length ) {
                        return;
                }
 
-               // Get href of the editsection link
-               href = $edit.prop( 'href' );
-
                // Headings can contain rich text.
                // Make sure to not block contextmenu events on (other) anchor tags
                // inside the heading (e.g. to do things like copy URL, open in new tab, ..).
                // e.target can be the heading, but it can also be anything inside the heading.
-               if ( href && e.target.nodeName.toLowerCase() !== 'a' ) {
-                       window.location = href;
+               if ( e.target.nodeName.toLowerCase() !== 'a' ) {
+                       // Trigger native HTMLElement click instead of opening URL (bug 43052)
                        e.preventDefault();
+                       $edit.get( 0 ).click();
                }
        } );
 } );