Ensure that addLinkAttributes is always called with a valid url parameter

There's no good reason for calling this helper function without a `url` parameter, and this way we can prevent that from happening.
Note how the `PDFOutlineViewer` call-site was already doing the right thing here, and only the `LinkAnnotationElement` call-site needed a small adjustment to make it work.
This commit is contained in:
Jonas Jenwald 2019-09-11 13:17:41 +02:00
parent b2856b16a5
commit 00efff532c
2 changed files with 21 additions and 22 deletions

View file

@ -294,20 +294,18 @@ class LinkAnnotationElement extends AnnotationElement {
const { data, linkService, } = this;
const link = document.createElement('a');
addLinkAttributes(link, {
url: data.url,
target: (data.newWindow ?
LinkTarget.BLANK : linkService.externalLinkTarget),
rel: linkService.externalLinkRel,
enabled: linkService.externalLinkEnabled,
});
if (!data.url) {
if (data.action) {
this._bindNamedAction(link, data.action);
} else {
this._bindLink(link, data.dest);
}
if (data.url) {
addLinkAttributes(link, {
url: data.url,
target: (data.newWindow ?
LinkTarget.BLANK : linkService.externalLinkTarget),
rel: linkService.externalLinkRel,
enabled: linkService.externalLinkEnabled,
});
} else if (data.action) {
this._bindNamedAction(link, data.action);
} else {
this._bindLink(link, data.dest);
}
this.container.appendChild(link);