Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
scaki authored Jun 6, 2024
1 parent b5078c3 commit c4ced8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/helpers/injectGoogleReCaptchaScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const injectGoogleReCaptchaScript = ({
render,
badge,
hl,
scriptContainer,
...params
}: InjectGoogleReCaptchaScriptParams) => {
const googleReCaptchaSrc = generateGoogleReCaptchaScriptSrc({
Expand All @@ -41,7 +42,6 @@ export const injectGoogleReCaptchaScript = ({
hl,
badge
});

const script = document.createElement('script');

Object.entries(params).forEach(([key, value]) => {
Expand All @@ -50,6 +50,9 @@ export const injectGoogleReCaptchaScript = ({

script.src = googleReCaptchaSrc;
script.onload = onload;

document[appendTo].appendChild(script);
if (appendTo === 'body' || appendTo === 'head') {
document[appendTo].appendChild(script);
}else{
appendTo.appendChild(script)
}
};
2 changes: 1 addition & 1 deletion packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export namespace GoogleReCaptcha {
export type Type = 'v3' | 'v2-invisible' | 'v2-checkbox';
export type Host = 'recaptcha.net' | 'google.com';
export interface Script extends Omit<Partial<HTMLScriptElement>, 'src'> {
appendTo?: 'body' | 'head';
appendTo?: 'body' | 'head' | ShadowRoot;
}

export type OptWidgetId = number | string;
Expand Down

0 comments on commit c4ced8d

Please sign in to comment.