From 98a9393eb019b279172454ebd7c3585290419bc6 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 2 Nov 2026 21:25:57 -0800 Subject: [PATCH] Test DOM prop completion with data attributes --- test/blackbox-tests/dom-props-completion.t | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 test/blackbox-tests/dom-props-completion.t diff --git a/test/blackbox-tests/dom-props-completion.t b/test/blackbox-tests/dom-props-completion.t new file mode 100644 index 000000000..6672892c7 --- /dev/null +++ b/test/blackbox-tests/dom-props-completion.t @@ -0,0 +1,56 @@ +DOM prop completion remains available while editing JSX with data attributes. + + $ 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 + +Build a valid component to initialize the Merlin configuration. + + $ cat > component.re < let element = + >
/>; + > EOF + $ dune build @mel + +Query completion before the closing tag, checking representative ordinary props. + + $ complete () { + > ocamlmerlin single complete-prefix -position 3:2 -prefix "" \ + > -filename component.re < component.re | + > jq -c '[.value.context[1].labels[].name | select(. == "?id" or . == "?onClick" or . == "?style")] | sort' + > } + $ complete + ["?id","?onClick","?style"] + +Merlin also completes editor buffers that do not type-check. Adding a data +attribute must not hide the ordinary DOM props, even before data attributes are +supported by the JSX PPX. + + $ cat > component.re < let element = + >
/>; + > EOF + $ complete + ["?id","?onClick","?style"] + +The same holds for an optional data attribute. + + $ cat > component.re < let element = + >
/>; + > EOF + $ complete + ["?id","?onClick","?style"]