(document: Document, id: string, newDefault: unknown)
| 51 | * the attribute was updated. |
| 52 | */ |
| 53 | export function writeVariableDefault(document: Document, id: string, newDefault: unknown): boolean { |
| 54 | const decls = readDecls(document); |
| 55 | if (!decls) return false; |
| 56 | const idx = indexOfId(decls.arr, id); |
| 57 | if (idx < 0) return false; // variable not declared — don't auto-add |
| 58 | decls.arr[idx] = { ...decls.arr[idx]!, default: newDefault }; |
| 59 | decls.htmlEl.setAttribute("data-composition-variables", JSON.stringify(decls.arr)); |
| 60 | return true; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Remove the `default` key from a variable declaration, restoring its |
no test coverage detected