Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/67345


Change subject: Set href in url/ext links in transcluded content.
......................................................................

Set href in url/ext links in transcluded content.

* A bug report on wikitext-l about href not being set on url links
  found in refs when transcluded via templates.

* In turns out the LinkHandler code had a bug where href was not
  being set on ext and url links when the links came from template
  content.

* Other minor cleanup.

* No change in test results.

Change-Id: I42f9b8683b1048b61e4e63947d6740efd253363b
---
M js/lib/ext.core.LinkHandler.js
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/45/67345/1

diff --git a/js/lib/ext.core.LinkHandler.js b/js/lib/ext.core.LinkHandler.js
index 843116f..6a0123b 100644
--- a/js/lib/ext.core.LinkHandler.js
+++ b/js/lib/ext.core.LinkHandler.js
@@ -858,8 +858,7 @@
        var env = this.manager.env,
                // distinguish media types
                // if image: parse options
-               rdfaAttrs = buildLinkAttrs(token.attribs, true, null, null ),
-               content = rdfaAttrs.content;
+               content = buildLinkAttrs(token.attribs, true, null, null 
).content;
 
        // extract options
        // TODO gwicke: abstract out!
@@ -1081,16 +1080,16 @@
                tagAttrs = [
                        new KV( 'src', href ),
                        new KV( 'alt', href.split('/').last() ),
-                       new KV('rel', 'mw:externalImage')
+                       new KV( 'rel', 'mw:externalImage' )
                ];
 
                // combine with existing rdfa attrs
                tagAttrs = buildLinkAttrs(token.attribs, false, null, 
tagAttrs).attribs;
-               dataAttribs.stx = "urllink";
                cb( { tokens: [ new SelfclosingTagTk('img', tagAttrs, 
dataAttribs) ] } );
        } else {
                tagAttrs = [
                        new KV( 'rel', 'mw:ExtLink/URL' )
+                       // href is set explicitly below
                ];
 
                // combine with existing rdfa attrs
@@ -1103,6 +1102,8 @@
                        // Since we messed with the text of the link, we need
                        // to preserve the original in the RT data. Or else.
                        builtTag.addNormalizedAttribute( 'href', txt, origTxt );
+               } else {
+                       builtTag.addAttribute( 'href', 
token.getAttribute('href') );
                }
 
                cb( {
@@ -1178,6 +1179,7 @@
 
                newAttrs = [
                        new KV('rel', rdfaType)
+                       // href is set explicitly below
                ];
                // combine with existing rdfa attrs
                newAttrs = buildLinkAttrs(token.attribs, false, null, 
newAttrs).attribs;
@@ -1198,6 +1200,8 @@
                        var tsr0a = dataAttribs.tsr[0] + 1,
                                tsr1a = dataAttribs.targetOff - 
(token.getAttribute('spaces') || '').length;
                        aStart.addNormalizedAttribute( 'href', href, 
env.page.src.substring(tsr0a, tsr1a) );
+               } else {
+                       aStart.addAttribute( 'href', href );
                }
                cb( {
                        tokens: [aStart].concat(content, [new EndTagTk('a')])

-- 
To view, visit https://gerrit.wikimedia.org/r/67345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I42f9b8683b1048b61e4e63947d6740efd253363b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to