We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2647bfb commit 2cddb12Copy full SHA for 2cddb12
src/runtime/internal/utils.ts
@@ -40,13 +40,13 @@ export function safe_not_equal(a, b) {
40
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
41
}
42
43
-const relative_to_absolute = (function() {
44
- const anchor = document.createElement('a');
45
- return function(url) {
46
- anchor.href = url;
47
- return anchor.href;
48
- };
49
-})();
+const relative_to_absolute : ((url: string) => string) & {anchor?: HTMLAnchorElement} = (url: string) => {
+ if (relative_to_absolute.anchor === undefined) {
+ relative_to_absolute.anchor = document.createElement('a');
+ }
+ relative_to_absolute.anchor.href = url;
+ return relative_to_absolute.anchor.href;
+}
50
51
export function src_url_equal(element_src, url) {
52
return element_src === relative_to_absolute(url);
0 commit comments