Skip to content

Commit 7e0b39d

Browse files
committed
fix: improve error message on v-model when using dot notation
1 parent a3f3b5f commit 7e0b39d

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

processors/src/main/java/com/axellience/vuegwt/processors/component/template/parser/TemplateParser.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,13 @@ private void processVModel(Attribute vModelAttribute) {
404404
String vModelValue = vModelAttribute.getValue();
405405
VariableInfo vModelDataField = context.findRootVariable(vModelValue);
406406
if (vModelDataField == null) {
407-
logger.error("Couldn't find @Data or @Computed for v-model \"" + vModelValue
408-
+ "\". V-Model is only supported on @Data and @Computed.");
407+
if (vModelValue.contains(".")) {
408+
logger.error("v-model doesn't support dot notation in Vue GWT: \"" + vModelValue
409+
+ "\". Try using a @Computed with a getter and a setter. Check our documentation on v-model for more information.");
410+
} else {
411+
logger.error("Couldn't find @Data or @Computed for v-model \"" + vModelValue
412+
+ "\". V-Model is only supported on @Data and @Computed. Check our documentation on v-model for more information.");
413+
}
409414
return;
410415
}
411416

processors/src/test/java/com/axellience/vuegwt/processors/component/vmodel/VModelTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ void vmodelWithInvalidField() {
2323
assertThat(compilation).hadErrorContaining(
2424
"Couldn't find @Data or @Computed for v-model \"nonExistingField\"");
2525
}
26+
27+
@Test
28+
@DisplayName("should throw an error when using a v-model with dot notation")
29+
void vmodelWithDotNotation() {
30+
Compilation compilation =
31+
javac()
32+
.withProcessors(new VueGwtProcessor())
33+
.compile(
34+
JavaFileObjects.forResource("vmodel/VModelDotNotationComponent.java"));
35+
36+
assertThat(compilation).hadErrorContaining(
37+
"v-model doesn't support dot notation in Vue GWT: \"dot.notation\"");
38+
}
2639
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<input type="text" v-model="dot.notation">
3+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package vmodel;
2+
3+
import com.axellience.vuegwt.core.annotations.component.Component;
4+
import com.axellience.vuegwt.core.client.component.IsVueComponent;
5+
6+
@Component
7+
public class VModelDotNotationComponent implements IsVueComponent {
8+
}

0 commit comments

Comments
 (0)