Skip to content

Commit

Permalink
Avoid an URI mismatch when looking for a filter id in the Firefox vie…
Browse files Browse the repository at this point in the history
…wer (bug 1821408)

We just replace the relative URL by an absolute one.
  • Loading branch information
calixteman committed Mar 10, 2023
1 parent 0338df2 commit be4b17e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ class FilterFactory {

#_defs;

#baseURL = null;

#document;

#id = 0;

constructor({ ownerDocument = globalThis.document } = {}) {
this.#document = ownerDocument;
this.#baseURL = this.#document?.URL ? new URL(this.#document.URL) : null;
}

get #cache() {
Expand Down Expand Up @@ -125,7 +128,16 @@ class FilterFactory {
// https://www.w3.org/TR/SVG11/filters.html#feComponentTransferElement

const id = `transfer_map_${this.#id++}`;
const url = `url(#${id})`;
let url;
if (this.#baseURL) {
this.#baseURL.hash = id;
// We use an absolute URL to avoid any issues in Firefox builtin viewer
// (see bug 1821408).
url = `url(${this.#baseURL})`;
} else {
url = `url(#${id})`;
}

this.#cache.set(maps, url);
this.#cache.set(key, url);

Expand Down

0 comments on commit be4b17e

Please sign in to comment.