We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 759c238 commit 35d57fbCopy full SHA for 35d57fb
packages/utilities/src/utilities/altlangs/altlangs.js
@@ -16,12 +16,15 @@ import root from 'window-or-global';
16
*
17
*/
18
function altlangs() {
19
- const links = root.document.querySelectorAll('link[rel="alternate"]');
20
- const langs = {};
+ let links = [];
+ let langs = {};
21
+ if (root.document) {
22
+ links = root.document.querySelectorAll('link[rel="alternate"]');
23
- links.forEach(link => {
- langs[link.getAttribute('hreflang')] = link.getAttribute('href');
24
- });
+ links.forEach(link => {
25
+ langs[link.getAttribute('hreflang')] = link.getAttribute('href');
26
+ });
27
+ }
28
29
return langs;
30
}
0 commit comments