Linker: Render selflinks as href-less classed <a>s, not <strong>s
authorJames D. Forrester <jforrester@wikimedia.org>
Thu, 16 Mar 2017 22:19:36 +0000 (15:19 -0700)
committerJforrester <jforrester@wikimedia.org>
Wed, 29 Mar 2017 23:12:17 +0000 (23:12 +0000)
Self-links are still semantically links, and representing them as <strong>s
is inelegant and more important a real pain to work with, especially in
contexts where they may change state (like inside an editor).

Instead, render them as <a>, with no href to avoid user agent style over-
rides and with a class to style them as before, named 'mw-selflink' to go
with 'mw-redirect'. This allows much easier adjustment later. The old CSS
class 'selflink' is retained for backwards compatibility, but deprecated.

Bug: T160480
Change-Id: If058843924c3b30c116df2520aef93a004d98a5d

RELEASE-NOTES-1.29
includes/Linker.php
resources/src/mediawiki.legacy/shared.css
tests/parser/parserTests.txt

index 793769f..2ced8a5 100644 (file)
@@ -276,6 +276,9 @@ changes to languages because of Phabricator reports.
   'EditPageGetCheckboxesDefinition', or 'EditPage::showStandardInputs:options'
   if you don't actually care about checkboxes and just want to add some HTML
   to the page.
+* Selflinks are now rendered as href-less <a> tags with the class mw-selflink
+  rather than <strong> tags. The old class name, "selflink", was deprecated
+  and will be removed in a future release. (T160480)
 
 == Compatibility ==
 
index 0c8d1c6..816271f 100644 (file)
@@ -164,10 +164,10 @@ class Linker {
        }
 
        /**
-        * Make appropriate markup for a link to the current article. This is
-        * currently rendered as the bold link text. The calling sequence is the
-        * same as the other make*LinkObj static functions, despite $query not
-        * being used.
+        * Make appropriate markup for a link to the current article. This is since
+        * MediaWiki 1.29.0 rendered as an <a> tag without an href and with a class
+        * showing the link text. The calling sequence is the same as for the other
+        * make*LinkObj static functions, but $query is not used.
         *
         * @since 1.16.3
         * @param Title $nt
@@ -179,7 +179,7 @@ class Linker {
         * @return string
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
-               $ret = "<strong class=\"selflink\">{$prefix}{$html}</strong>{$trail}";
+               $ret = "<a class=\"mw-selflink selflink\">{$prefix}{$html}</a>{$trail}";
                if ( !Hooks::run( 'SelfLinkBegin', [ $nt, &$html, &$trail, &$prefix, &$ret ] ) ) {
                        return $ret;
                }
@@ -188,7 +188,7 @@ class Linker {
                        $html = htmlspecialchars( $nt->getPrefixedText() );
                }
                list( $inside, $trail ) = self::splitTrail( $trail );
-               return "<strong class=\"selflink\">{$prefix}{$html}{$inside}</strong>{$trail}";
+               return "<a class=\"mw-selflink selflink\">{$prefix}{$html}{$inside}</a>{$trail}";
        }
 
        /**
index ff0c0e3..6ced6dc 100644 (file)
@@ -322,6 +322,17 @@ a.new {
        color: #ba0000;
 }
 
+/* self links */
+a.mw-selflink {
+       color: inherit;
+       font-weight: bold;
+       text-decoration: inherit;
+}
+a.mw-selflink:hover {
+       cursor: inherit;
+       text-decoration: inherit;
+}
+
 /* Plainlinks - this can be used to switch
  * off special external link styling */
 .plainlinks a.external {
index be6e3a8..2def875 100644 (file)
@@ -8015,10 +8015,10 @@ title=[[Bug462]]
 !! wikitext
 [[Bu&#103;462]] [[Bug462]]
 !! html/php
-<p><strong class="selflink">Bu&#103;462</strong> <strong class="selflink">Bug462</strong>
+<p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
 </p>
 !! html/php+tidy
-<p><strong class="selflink">Bug462</strong> <strong class="selflink">Bug462</strong></p>
+<p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
 !! end
@@ -8047,7 +8047,7 @@ title=[[0]]
 !! wikitext
 [[0]]
 !! html
-<p><strong class="selflink">0</strong>
+<p><a class="mw-selflink selflink">0</a>
 </p>
 !!end
 
@@ -8503,7 +8503,7 @@ parsoid=wt2html,wt2wt,html2html
 !! wikitext
 [[local:Main Page]]
 !! html/php
-<p><strong class="selflink">local:Main Page</strong>
+<p><a class="mw-selflink selflink">local:Main Page</a>
 </p>
 !! html/parsoid
 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
@@ -20327,7 +20327,7 @@ title=[[Dunav]] language=sr
 !! wikitext
 Both [[Dunav]] and [[Дунав]] are names for this river.
 !! html
-<p>Both <strong class="selflink">Dunav</strong> and <strong class="selflink">Дунав</strong> are names for this river.
+<p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
 </p>
 !!end
 
@@ -20344,7 +20344,7 @@ title=[[Duna]] language=sr
 !! wikitext
 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
 !! html
-<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <strong class="selflink">Duna</strong> and <strong class="selflink">Dуна</strong> are still self-links.
+<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <a class="mw-selflink selflink">Duna</a> and <a class="mw-selflink selflink">Dуна</a> are still self-links.
 </p>
 !! end
 
@@ -20355,7 +20355,7 @@ title=[[Duna]] language=sr
 !! wikitext
 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
 !! html
-<p><strong class="selflink">Dуна</strong> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
+<p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
 </p>
 !! end