Feed abstract: Add <base>

Fixes broken relative (or protocol-relative) images.
This commit is contained in:
Abe Jellinek 2024-04-26 15:45:30 -04:00 committed by Dan Stillman
parent c32a352ecc
commit 4fe7d6fa0e
2 changed files with 9 additions and 5 deletions

View file

@ -10,10 +10,13 @@ class FeedAbstractChild extends JSWindowActorChild {
this._stylesheetPromise = this.sendQuery('getStylesheet'); this._stylesheetPromise = this.sendQuery('getStylesheet');
} }
async receiveMessage({ name, data }) { async receiveMessage({ name, data: { url, html } }) {
switch (name) { switch (name) {
case "setContent": { case "setContent": {
this.document.documentElement.innerHTML = data; let base = this.document.createElement("base");
base.href = url;
this.document.head.replaceChildren(base);
this.document.body.innerHTML = html;
break; break;
} }
} }

View file

@ -126,13 +126,14 @@
} }
async _renderFeedItem() { async _renderFeedItem() {
let abstract = this.item.getField('abstractNote'); let url = this.item.library.url;
let html = this.item.getField('abstractNote');
this._abstractField.hidden = true; this._abstractField.hidden = true;
this._feedAbstractBrowser.hidden = false; this._feedAbstractBrowser.hidden = false;
this._section.summary = Zotero.Utilities.cleanTags(abstract); this._section.summary = Zotero.Utilities.cleanTags(html);
let actor = this._feedAbstractBrowser.browsingContext.currentWindowGlobal.getActor('FeedAbstract'); let actor = this._feedAbstractBrowser.browsingContext.currentWindowGlobal.getActor('FeedAbstract');
await actor.sendQuery('setContent', abstract); await actor.sendQuery('setContent', { url, html });
} }
_renderRegularItem() { _renderRegularItem() {