Skip to content

Commit 5722978

Browse files
committed
Merge pull request #23 from tjokimie/ensure-grecaptcha-reset-exists
Ensure grecaptcha reset exists
2 parents d65734f + 1d5f3f1 commit 5722978

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/angular-no-captcha.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ angular
4545
'noCAPTCHA',
4646
'googleGrecaptcha',
4747
'$document',
48-
function (noCaptcha, googleGrecaptcha, $document){
48+
'$window',
49+
function (noCaptcha, googleGrecaptcha, $document, $window){
4950
/**
5051
* Removes all .pls-container elements
5152
*
@@ -107,18 +108,20 @@ angular
107108
}
108109

109110
googleGrecaptcha.then(function (){
110-
widgetId = grecaptcha.render(
111+
widgetId = $window.grecaptcha.render(
111112
element[0],
112113
grecaptchaCreateParameters
113114
);
114115
control.reset = function (){
115-
grecaptcha.reset(widgetId);
116+
$window.grecaptcha.reset(widgetId);
116117
scope.gRecaptchaResponse = null;
117118
};
118119
});
119120

120121
scope.$on('$destroy', function (){
121-
grecaptcha.reset(widgetId);
122+
if($window.grecaptcha) {
123+
$window.grecaptcha.reset(widgetId);
124+
}
122125
removePLSContainers();
123126
});
124127
}

0 commit comments

Comments
 (0)