File tree 3 files changed +14
-0
lines changed
3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
7
7
## [ Unreleased]
8
8
- init module with Cookies & Browser redirection on Homepage only
9
+ - handling of missing common JS library
9
10
- remove dependency on JQuery
Original file line number Diff line number Diff line change @@ -43,7 +43,13 @@ Drupal.homeRedirectLang.setPreferredLanguage('fr');
43
43
```
44
44
45
45
``` javascript
46
+ // Prevent attempting to attach cookie if the common library is not available.
47
+ if (typeof Drupal .homeRedirectLang == " undefined" ) {
48
+ return ;
49
+ }
50
+
46
51
let links = document .querySelectorAll (' .language-link' );
52
+
47
53
links .forEach (link => {
48
54
link .addEventListener (' click' , function (event ) {
49
55
var hreflang = event .target .getAttribute (' hreflang' );
Original file line number Diff line number Diff line change 15
15
*/
16
16
Drupal . behaviors . homeRedirectLangSwitcher = {
17
17
attach : function ( context ) {
18
+
19
+ // Prevent attempting to attach cookie if the common library is not available.
20
+ if ( typeof Drupal . homeRedirectLang == "undefined" ) {
21
+ return ;
22
+ }
23
+
18
24
let links = document . querySelectorAll ( '.language-switcher-language-url .language-link' ) ;
25
+
19
26
links . forEach ( link => {
20
27
link . addEventListener ( 'click' , function ( event ) {
21
28
var hreflang = event . target . getAttribute ( 'hreflang' ) ;
You can’t perform that action at this time.
0 commit comments