Read the default value for a variable id from the parsed document.
(parsed: ReturnType<typeof parseMutable>, id: string)
| 59 | |
| 60 | /** Read the default value for a variable id from the parsed document. */ |
| 61 | function readVarDefault(parsed: ReturnType<typeof parseMutable>, id: string): unknown { |
| 62 | const raw = parsed.document.documentElement?.getAttribute("data-composition-variables"); |
| 63 | if (!raw) return undefined; |
| 64 | const arr = JSON.parse(raw) as Array<{ id: string; default: unknown }>; |
| 65 | return arr.find((v) => v.id === id)?.default; |
| 66 | } |
| 67 | |
| 68 | // ─── setStyle ──────────────────────────────────────────────────────────────── |
| 69 |
no test coverage detected