Skip to content

Commit 35d57fb

Browse files
committed
fix(footer): add check for root document for ssr
1 parent 759c238 commit 35d57fb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/utilities/src/utilities/altlangs/altlangs.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ import root from 'window-or-global';
1616
*
1717
*/
1818
function altlangs() {
19-
const links = root.document.querySelectorAll('link[rel="alternate"]');
20-
const langs = {};
19+
let links = [];
20+
let langs = {};
21+
if (root.document) {
22+
links = root.document.querySelectorAll('link[rel="alternate"]');
2123

22-
links.forEach(link => {
23-
langs[link.getAttribute('hreflang')] = link.getAttribute('href');
24-
});
24+
links.forEach(link => {
25+
langs[link.getAttribute('hreflang')] = link.getAttribute('href');
26+
});
27+
}
2528

2629
return langs;
2730
}

0 commit comments

Comments
 (0)