diff --git a/.changeset/fresh-jobs-smash.md b/.changeset/fresh-jobs-smash.md new file mode 100644 index 00000000..771afc9a --- /dev/null +++ b/.changeset/fresh-jobs-smash.md @@ -0,0 +1,5 @@ +--- +'@svelte-put/cloudflare-turnstile': patch +--- + +correctly fallback for tabindex & retry-interval diff --git a/packages/actions/cloudflare-turnstile/src/turnstile.js b/packages/actions/cloudflare-turnstile/src/turnstile.js index 25ba9793..15095b3b 100644 --- a/packages/actions/cloudflare-turnstile/src/turnstile.js +++ b/packages/actions/cloudflare-turnstile/src/turnstile.js @@ -51,7 +51,9 @@ export function turnstile(node) { node.getAttribute('turnstile-theme') ) ?? undefined, language: node.getAttribute('turnstile-language') ?? undefined, - tabindex: parseInt(node.getAttribute('turnstile-tabindex') ?? '0'), + tabindex: node.hasAttribute('turnstile-tabindex') + ? parseInt(node.getAttribute('turnstile-tabindex') || '0') || 0 + : undefined, 'response-field': node.hasAttribute('turnstile-response-field'), 'response-field-name': node.getAttribute('turnstile-response-field-name') ?? undefined, size: @@ -62,7 +64,9 @@ export function turnstile(node) { /** @type {import('./public').TurnstileConfig['retry']} */ ( node.getAttribute('turnstile-retry') ) ?? undefined, - 'retry-interval': parseInt(node.getAttribute('turnstile-retry-interval') ?? '0'), + 'retry-interval': node.hasAttribute('turnstile-retry-interval') + ? parseInt(node.getAttribute('turnstile-retry-interval') || '8000') || 8000 + : undefined, 'refresh-expired': /** @type {import('./public').TurnstileConfig['refresh-expired']} */ ( node.getAttribute('turnstile-refresh-expired')