Skip to content

Commit

Permalink
Fix undefined error if there is no lang attribute on the html tag
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauriC committed Jun 6, 2024
1 parent 3462185 commit 5a2252b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions tarteaucitron.js
Original file line number Diff line number Diff line change
Expand Up @@ -2053,8 +2053,10 @@ var tarteaucitron = {
}

// get the html lang
if (availableLanguages.indexOf(document.documentElement.getAttribute("lang").substr(0, 2)) !== -1) {
return document.documentElement.getAttribute("lang").substr(0, 2);
if (document.documentElement.getAttribute("lang") !== undefined && document.documentElement.getAttribute("lang") !== null) {
if (availableLanguages.indexOf(document.documentElement.getAttribute("lang").substr(0, 2)) !== -1) {
return document.documentElement.getAttribute("lang").substr(0, 2);
}
}

if (!navigator) { return defaultLanguage; }
Expand Down
2 changes: 1 addition & 1 deletion tarteaucitron.min.js

Large diffs are not rendered by default.

0 comments on commit 5a2252b

Please sign in to comment.