diff options
| author | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2020-04-28 14:55:12 +0900 |
|---|---|---|
| committer | Acid Chicken (硫酸鶏) <root@acid-chicken.com> | 2020-04-28 14:55:12 +0900 |
| commit | b862c055ae81a0ed1f239fb43edf699cd70f711e (patch) | |
| tree | e9ba6d630c0f6a5e799d462b1e2284b943c8bd83 /src/client/components | |
| parent | Add support for hCaptcha (diff) | |
| download | sharkey-b862c055ae81a0ed1f239fb43edf699cd70f711e.tar.gz sharkey-b862c055ae81a0ed1f239fb43edf699cd70f711e.tar.bz2 sharkey-b862c055ae81a0ed1f239fb43edf699cd70f711e.zip | |
Fix bug
Diffstat (limited to 'src/client/components')
| -rw-r--r-- | src/client/components/hcaptcha.vue | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/components/hcaptcha.vue b/src/client/components/hcaptcha.vue index e54eb314a3..4711b303d7 100644 --- a/src/client/components/hcaptcha.vue +++ b/src/client/components/hcaptcha.vue @@ -23,7 +23,7 @@ export default Vue.extend({ props: { sitekey: { type: String, - required: true, + required: true, }, value: { type: String, @@ -37,13 +37,22 @@ export default Vue.extend({ }, created() { - if (window.hcaptcha) { + if (window.hcaptcha) { // loaded this.available = true; } else { + const alreadyLoading = document.getElementById('hcaptcha'); + + if (alreadyLoading) { // loading + alreadyLoading.addEventListener('load', () => this.available = true); + + return; + } // init + const script = document.createElement('script'); script.addEventListener('load', () => this.available = true); - script.src = 'https://hcaptcha.com/1/api.js?render=explicit'; script.async = true; + script.id = 'hcaptcha'; + script.src = 'https://hcaptcha.com/1/api.js?render=explicit'; document.head.appendChild(script); } }, |