Rename uri to href

This commit is contained in:
John Factotum
2023-05-03 17:22:55 +08:00
parent 902cd9ad46
commit 9e4ef02fa8
+7 -7
View File
@@ -109,14 +109,14 @@ export class View {
for (const a of doc.querySelectorAll('a[href]')) for (const a of doc.querySelectorAll('a[href]'))
a.addEventListener('click', e => { a.addEventListener('click', e => {
e.preventDefault() e.preventDefault()
const href = a.getAttribute('href') const href_ = a.getAttribute('href')
const uri = section?.resolveHref?.(href) ?? href const href = section?.resolveHref?.(href_) ?? href_
if (book?.isExternal?.(uri)) if (book?.isExternal?.(href))
Promise.resolve(emit?.({ type: 'external-link', a, uri })) Promise.resolve(emit?.({ type: 'external-link', a, href }))
.then(x => x ? null : window.open(uri, '_blank')) .then(x => x ? null : window.open(href, '_blank'))
.catch(e => console.error(e)) .catch(e => console.error(e))
else Promise.resolve(emit?.({ type: 'link', a, uri })) else Promise.resolve(emit?.({ type: 'link', a, href }))
.then(x => x ? null : this.goTo(uri)) .then(x => x ? null : this.goTo(href))
.catch(e => console.error(e)) .catch(e => console.error(e))
}) })
} }