From b869848e76382a346907641c1c41d80b4441bddb Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 7 Nov 2026 12:52:22 -0800 Subject: [PATCH] Test DOM prop completion in partial and nested JSX --- test/blackbox-tests/dom-props-completion.t | 56 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/test/blackbox-tests/dom-props-completion.t b/test/blackbox-tests/dom-props-completion.t index 6672892c7..1fd85c1b9 100644 --- a/test/blackbox-tests/dom-props-completion.t +++ b/test/blackbox-tests/dom-props-completion.t @@ -26,9 +26,9 @@ Build a valid component to initialize the Merlin configuration. Query completion before the closing tag, checking representative ordinary props. $ complete () { - > ocamlmerlin single complete-prefix -position 3:2 -prefix "" \ + > ocamlmerlin single complete-prefix -position "${1:-3:2}" -prefix "${2:-}" \ > -filename component.re < component.re | - > jq -c '[.value.context[1].labels[].name | select(. == "?id" or . == "?onClick" or . == "?style")] | sort' + > jq -c '[.value.context[1].labels[].name | select(. == "?id" or . == "?onClick" or . == "?style" or . == "?className" or startswith("~"))] | sort' > } $ complete ["?id","?onClick","?style"] @@ -54,3 +54,55 @@ The same holds for an optional data attribute. > EOF $ complete ["?id","?onClick","?style"] + +Partially typed names still complete ordinary props. Already supplied props and +generated helper arguments must not appear in the suggestions. + + $ cat > component.re < let element = + >
onC />; + > EOF + $ complete 3:5 onC + ["?id","?onClick","?style"] + + $ cat > component.re < let element = + >
onC />; + > EOF + $ complete 3:5 onC + ["?id","?onClick","?style"] + +Completion also works between data attributes, before any ordinary prop is set. + + $ cat > component.re < let element = + >
cla dataBar="last" />; + > EOF + $ complete 3:5 cla + ["?className","?id","?onClick","?style"] + +Nested JSX keeps its own completion context, including inside ordinary prop +expressions. + + $ cat > component.re < let element = + >
+ >
; + > EOF + $ complete 4:9 onC + ["?id","?onClick","?style"] + + $ cat > component.re < let element = + >