ensure anchor attribute is removed if anchor value is empty

This commit is contained in:
Nathan Woulfe
2018-06-17 19:18:16 +10:00
parent d327299d76
commit ef580558b1

View File

@@ -686,12 +686,12 @@ function tinyMceService($log, imageHelper, $http, $timeout, macroResource, macro
name: anchor.attr("title"), name: anchor.attr("title"),
url: anchor.attr("href"), url: anchor.attr("href"),
target: anchor.attr("target") target: anchor.attr("target")
}; };
// split the URL to check for an anchor or querystring, then add that value to the currentTarget object // drop the lead char from the anchor text, if it has a value
var urlParts = currentTarget.url.split(/(\?|#)/); var anchorVal = anchor.data("anchor");
if (urlParts.length === 3) { if (anchorVal) {
currentTarget.anchor = urlParts[2]; currentTarget.anchor = anchorVal.substring(1);
} }
//locallink detection, we do this here, to avoid poluting the dialogservice //locallink detection, we do this here, to avoid poluting the dialogservice
@@ -795,6 +795,7 @@ function tinyMceService($log, imageHelper, $http, $timeout, macroResource, macro
target: target.target ? target.target : null, target: target.target ? target.target : null,
rel: target.rel ? target.rel : null rel: target.rel ? target.rel : null
}; };
if (hasUdi) { if (hasUdi) {
a["data-udi"] = target.udi; a["data-udi"] = target.udi;
} }
@@ -805,8 +806,10 @@ function tinyMceService($log, imageHelper, $http, $timeout, macroResource, macro
if (target.anchor) { if (target.anchor) {
a["data-anchor"] = target.anchor; a["data-anchor"] = target.anchor;
a.href = a.href + target.anchor; a.href = a.href + target.anchor;
} else {
a["data-anchor"] = null;
} }
return a; return a;
} }