mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +02:00
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:
parent
b2856b16a5
commit
00efff532c
2 changed files with 21 additions and 22 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue