HS toggle style: parse between/cycle, runtime, mock style dict

Parser:
- Reorder toggle style parsing: target before between clause
- Handle "indexed" keyword, "indexed by" syntax
- Use parse-atom (not parse-expr) for between values to avoid
  consuming "and" as boolean operator
- Support 3-4 value cycles via toggle-style-cycle

Compiler:
- Add toggle-style-cycle dispatch → hs-toggle-style-cycle!

Runtime:
- Add hs-toggle-style-between! (2-value toggle)
- Add hs-toggle-style-cycle! (N-value round-robin)

Mock DOM:
- Parse CSS strings from setAttribute "style" into style sub-dict
  so dom-get-style/dom-set-style work correctly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-18 21:35:00 +00:00
parent 06bed36272
commit 00bf13a230
4 changed files with 156 additions and 77 deletions

View File

@@ -1815,6 +1815,22 @@ let run_spec_tests env test_files =
Hashtbl.replace d "className" (String sv);
end;
if name = "disabled" then Hashtbl.replace d "disabled" (Bool true);
if name = "style" then begin
(* Parse CSS string into the style sub-dict *)
let style_d = match Hashtbl.find_opt d "style" with Some (Dict s) -> s | _ ->
let s = Hashtbl.create 4 in Hashtbl.replace d "style" (Dict s); s in
let parts = String.split_on_char ';' sv in
List.iter (fun part ->
let part = String.trim part in
if String.length part > 0 then
match String.index_opt part ':' with
| Some i ->
let prop = String.trim (String.sub part 0 i) in
let value = String.trim (String.sub part (i+1) (String.length part - i - 1)) in
Hashtbl.replace style_d prop (String value)
| None -> ()
) parts
end;
Nil
| _ -> Nil)
| "getAttribute" ->