diff --git a/cjs/html/anchor-element.js b/cjs/html/anchor-element.js index e0c17905..bd3928ca 100644 --- a/cjs/html/anchor-element.js +++ b/cjs/html/anchor-element.js @@ -15,10 +15,10 @@ class HTMLAnchorElement extends HTMLElement { } /* c8 ignore start */ // copy paste from img.src, already covered - get href() { return encodeURI(stringAttribute.get(this, 'href')); } + get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); } set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); } - get download() { return encodeURI(stringAttribute.get(this, 'download')); } + get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); } set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); } get target() { return stringAttribute.get(this, 'target'); } diff --git a/esm/html/anchor-element.js b/esm/html/anchor-element.js index 5f8d1726..b555c346 100644 --- a/esm/html/anchor-element.js +++ b/esm/html/anchor-element.js @@ -14,10 +14,10 @@ class HTMLAnchorElement extends HTMLElement { } /* c8 ignore start */ // copy paste from img.src, already covered - get href() { return encodeURI(stringAttribute.get(this, 'href')); } + get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); } set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); } - get download() { return encodeURI(stringAttribute.get(this, 'download')); } + get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); } set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); } get target() { return stringAttribute.get(this, 'target'); } diff --git a/test/html/anchor-element.js b/test/html/anchor-element.js index 77f6d4f9..43d1e387 100644 --- a/test/html/anchor-element.js +++ b/test/html/anchor-element.js @@ -11,4 +11,5 @@ a.setAttribute('href', 'https://google.com/?q=1&page=2&test="'); assert(a.toString(), 'click me'); a.setAttribute('href', 'https://google.com/?q=asd&lol=<2>"'); assert(a.href, 'https://google.com/?q=asd&lol=%3C2%3E%22'); - +a.setAttribute('href', 'https://google.com/path%20to%20some%20file.pdf'); +assert(a.href, 'https://google.com/path%20to%20some%20file.pdf'); diff --git a/worker.js b/worker.js index 5b4ddc8c..3ba9c3d5 100644 --- a/worker.js +++ b/worker.js @@ -11049,10 +11049,10 @@ class HTMLAnchorElement extends HTMLElement { } /* c8 ignore start */ // copy paste from img.src, already covered - get href() { return encodeURI(stringAttribute.get(this, 'href')); } + get href() { return encodeURI(decodeURI(stringAttribute.get(this, 'href'))); } set href(value) { stringAttribute.set(this, 'href', decodeURI(value)); } - get download() { return encodeURI(stringAttribute.get(this, 'download')); } + get download() { return encodeURI(decodeURI(stringAttribute.get(this, 'download'))); } set download(value) { stringAttribute.set(this, 'download', decodeURI(value)); } get target() { return stringAttribute.get(this, 'target'); }