mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
@@ -836,7 +836,6 @@ class Loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// replace hrefs (excluding anchors)
|
// replace hrefs (excluding anchors)
|
||||||
// TODO: srcset?
|
|
||||||
const replace = async (el, attr) => el.setAttribute(attr,
|
const replace = async (el, attr) => el.setAttribute(attr,
|
||||||
await this.loadHref(el.getAttribute(attr), href, parents))
|
await this.loadHref(el.getAttribute(attr), href, parents))
|
||||||
for (const el of doc.querySelectorAll('link[href]')) await replace(el, 'href')
|
for (const el of doc.querySelectorAll('link[href]')) await replace(el, 'href')
|
||||||
@@ -846,6 +845,11 @@ class Loader {
|
|||||||
for (const el of doc.querySelectorAll('[*|href]:not([href])'))
|
for (const el of doc.querySelectorAll('[*|href]:not([href])'))
|
||||||
el.setAttributeNS(NS.XLINK, 'href', await this.loadHref(
|
el.setAttributeNS(NS.XLINK, 'href', await this.loadHref(
|
||||||
el.getAttributeNS(NS.XLINK, 'href'), href, parents))
|
el.getAttributeNS(NS.XLINK, 'href'), href, parents))
|
||||||
|
for (const el of doc.querySelectorAll('[srcset]'))
|
||||||
|
el.setAttribute('srcset', await replaceSeries(el.getAttribute('srcset'),
|
||||||
|
/(\s*)(.+?)\s*((?:\s[\d.]+[wx])+\s*(?:,|$)|,\s+|$)/g,
|
||||||
|
(_, p1, p2, p3) => this.loadHref(p2, href, parents)
|
||||||
|
.then(p2 => `${p1}${p2}${p3}`)))
|
||||||
// replace inline styles
|
// replace inline styles
|
||||||
for (const el of doc.querySelectorAll('style'))
|
for (const el of doc.querySelectorAll('style'))
|
||||||
if (el.textContent) el.textContent =
|
if (el.textContent) el.textContent =
|
||||||
|
|||||||
Reference in New Issue
Block a user