Skip to content

Commit

Permalink
fix(cloudflare-turnstile): correctly fallback int attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Feb 2, 2024
1 parent 55ffc6e commit dbb6148
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-jobs-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@svelte-put/cloudflare-turnstile': patch
---

correctly fallback for tabindex & retry-interval
8 changes: 6 additions & 2 deletions packages/actions/cloudflare-turnstile/src/turnstile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')
Expand Down

0 comments on commit dbb6148

Please sign in to comment.