From b862c055ae81a0ed1f239fb43edf699cd70f711e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Tue, 28 Apr 2020 14:55:12 +0900 Subject: [PATCH] Fix bug --- src/client/components/hcaptcha.vue | 15 ++++++++++++--- 1 file 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); } },