Skip to content

Commit 2cddb12

Browse files
committed
Fix tree-shakability
1 parent 2647bfb commit 2cddb12

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/runtime/internal/utils.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ export function safe_not_equal(a, b) {
4040
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
4141
}
4242

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-
})();
43+
const relative_to_absolute : ((url: string) => string) & {anchor?: HTMLAnchorElement} = (url: string) => {
44+
if (relative_to_absolute.anchor === undefined) {
45+
relative_to_absolute.anchor = document.createElement('a');
46+
}
47+
relative_to_absolute.anchor.href = url;
48+
return relative_to_absolute.anchor.href;
49+
}
5050

5151
export function src_url_equal(element_src, url) {
5252
return element_src === relative_to_absolute(url);

0 commit comments

Comments
 (0)