Skip to content

Commit

Permalink
Update g-recaptcha.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Pixelik authored Jan 9, 2024
1 parent b2fb2ef commit 16c9387
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions addon/components/g-recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,23 @@ export default class GRecaptchaComponent extends Component {

@action
_initialize(element) {
window[`__ember_g_recaptcha_${this.elementId}_onload`] = () => {
const globalName = `__ember_g_recaptcha_${this.elementId}_onload`;

window[globalName] = () => {
this._render(element);
};

const baseUrl = [
`${
this.config['jsUrl'] || 'https://www.google.com/recaptcha/api.js'
}?render=explicit`,
`onload=__ember_g_recaptcha_${this.elementId}_onload`,
this.config['hl'] ? `hl=${this.config['hl']}` : '',
].join('&');
let baseUrl = [
`${this.config['jsUrl'] || 'https://www.google.com/recaptcha/api.js'}?render=explicit`,
`onload=${globalName}`
];

if (this.config['hl']) {
baseUrl.push(`hl=${this.config['hl']}`);
}

if (!this.options['skip']) {
this._appendScript(
`${baseUrl}&onload=__ember_g_recaptcha_${this.elementId}_onload`
);
this._appendScript(baseUrl.join('&'));
} else {
this._render();
}
Expand Down

0 comments on commit 16c9387

Please sign in to comment.