File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 37
37
},
38
38
methods: {
39
39
init () {
40
- if (! ( ' grecaptcha ' in window )) {
40
+ if (! document . getElementById ( ' gRecaptchaScript ' )) {
41
41
42
- window .gRecaptchaOnLoad = this .render ;
42
+ window .gRecaptchaOnLoadCallbacks = [this .render ];
43
+ window .gRecaptchaOnLoad = function () {
44
+ for (let i = 0 ; i < window .gRecaptchaOnLoadCallbacks .length ; i++ ) {
45
+ window .gRecaptchaOnLoadCallbacks [i]();
46
+ }
47
+ delete window .gRecaptchaOnLoadCallbacks ;
48
+ delete window .gRecaptchaOnLoad ;
49
+ };
43
50
44
51
let recaptchaScript = document .createElement (' script' );
45
52
recaptchaScript .setAttribute (' src' , ' https://www.google.com/recaptcha/api.js?render=explicit&onload=gRecaptchaOnLoad' );
53
+ recaptchaScript .setAttribute (' id' , ' gRecaptchaScript' );
46
54
recaptchaScript .async = true ;
47
55
recaptchaScript .defer = true ;
48
56
document .head .appendChild (recaptchaScript);
49
57
58
+ } else if (! window .grecaptcha || ! window .grecaptcha .render ) {
59
+ window .gRecaptchaOnLoadCallbacks .push (this .render );
50
60
} else {
51
61
this .render ();
52
62
}
You can’t perform that action at this time.
0 commit comments