From 5ff2aa08b2c4f37eb1fa98f91e04e0322f735593 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 24 Oct 2026 16:12:09 -0700 Subject: [PATCH] Test DOM prop typing and unsupported data attributes --- test/blackbox-tests/data-attributes.t/run.t | 47 ++++ test/blackbox-tests/dom-props.t/input.re.in | 45 ++++ test/blackbox-tests/dom-props.t/run.t | 227 ++++++++++++++++++++ 3 files changed, 319 insertions(+) create mode 100644 test/blackbox-tests/data-attributes.t/run.t create mode 100644 test/blackbox-tests/dom-props.t/input.re.in create mode 100644 test/blackbox-tests/dom-props.t/run.t diff --git a/test/blackbox-tests/data-attributes.t/run.t b/test/blackbox-tests/data-attributes.t/run.t new file mode 100644 index 000000000..c9b13a7bb --- /dev/null +++ b/test/blackbox-tests/data-attributes.t/run.t @@ -0,0 +1,47 @@ +DOM JSX currently rejects arbitrary data attributes. These expected failures +document the limitation before adding support for them. + + $ cat > dune-project < (lang dune 3.8) + > (using melange 0.1) + > EOF + + $ cat > dune < (melange.emit + > (target output) + > (alias mel) + > (emit_stdlib false) + > (libraries reason-react) + > (preprocess (pps melange.ppx reason-react-ppx))) + > EOF + +Check the failure status before showing the final diagnostic, since the full +list of accepted DOM props is long. + + $ cat > input.re < let element =
; + > EOF + $ dune build @mel > error.log 2>&1 + [1] + $ tail -n 1 error.log + This argument cannot be applied with label ~dataFoo + +Optional data attributes are also rejected. + + $ cat > input.re < let element = (~dataFoo=?, ()) =>
; + > EOF + $ dune build @mel > error.log 2>&1 + [1] + $ tail -n 1 error.log + This argument cannot be applied with label ?dataFoo + +SVG elements have the same limitation. + + $ cat > input.re < let element = ; + > EOF + $ dune build @mel > error.log 2>&1 + [1] + $ tail -n 1 error.log + This argument cannot be applied with label ~dataFoo diff --git a/test/blackbox-tests/dom-props.t/input.re.in b/test/blackbox-tests/dom-props.t/input.re.in new file mode 100644 index 000000000..d0ddab268 --- /dev/null +++ b/test/blackbox-tests/dom-props.t/input.re.in @@ -0,0 +1,45 @@ +let first =
; +let second =
; +let ordinaryData = ; + +let optional = (~className=?, ()) =>
; + +let renamed = +
; + +let withChildren =
; + +let withRefAndEvent = (elementRef, handleClick) => +