mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
Clean up sHref handling a bit
* sHref is now always a string * fixes crasher when sHref is not set Change-Id: If5756948ac6bc26c2d7c04d970b5aba5331cb8bb
This commit is contained in:
parent
e117f09362
commit
33dc9abb0d
|
@ -49,7 +49,7 @@ WikiLinkHandler.prototype.onWikiLink = function ( token, frame, cb ) {
|
|||
),
|
||||
content = token.attribs.slice(2);
|
||||
if ( href !== normalizedHref ) {
|
||||
obj.dataAttribs.sHref = href;
|
||||
obj.dataAttribs.sHref = env.tokensToString( href );
|
||||
}
|
||||
//console.warn('content: ' + JSON.stringify( content, null, 2 ) );
|
||||
// XXX: handle trail
|
||||
|
|
|
@ -241,14 +241,13 @@ WSP._linkHandler = function( state, token ) {
|
|||
var tail = tokenData.tail;
|
||||
if ( tail && tail.length ) {
|
||||
state.dropTail = tail;
|
||||
target = tokenData.gc ? tokenData.sHref[0] : target.replace( /_/g, ' ' );
|
||||
target = tokenData.gc ? tokenData.sHref : target.replace( /_/g, ' ' );
|
||||
} else {
|
||||
// SSS: Why is sHref an array instead of a string?
|
||||
var origLinkTgt = tokenData.sHref[0];
|
||||
var origLinkTgt = tokenData.sHref;
|
||||
if (origLinkTgt) {
|
||||
//console.warn( JSON.stringify( tokenData.sHref ) );
|
||||
// SSS FIXME: Why was resolveTitle wrapping this? Also, why do we require normalizeTitle here?
|
||||
var normalizedOrigLinkTgt = env.normalizeTitle(env.tokensToString(origLinkTgt));
|
||||
// Normalize the source target so that we can compare it
|
||||
// with href.
|
||||
var normalizedOrigLinkTgt = env.normalizeTitle( env.tokensToString(origLinkTgt) );
|
||||
if ( normalizedOrigLinkTgt === target ) {
|
||||
// Non-standard capitalization
|
||||
target = origLinkTgt;
|
||||
|
|
Loading…
Reference in a new issue