Skip to content

xxx is not a valid value for v-model. Expected: v-model #79

@anyesu

Description

@anyesu

First of all, I'm sorry. This bug should belong to the intellij-community project, but I don't know how to test it in that project. I see that the author of the relevant code is also you, so I came here.

ref: https://youtrack.jetbrains.com/issue/WEB-52219

Environment

OS IntelliJ IDEA 2023.3.2
Windows 10 10.0.19045 #IU-233.13135.103

Steps to reproduce

  1. Create an empty project and install dependencies.

    npm i vue @nutui/nutui
  2. Create a Vue file.

    <template>
      <nut-pull-refresh v-model="refresh" />
    </template>
    <script setup lang="ts">
    import { ref } from 'vue';
    
    const refresh = ref(false);
    </script>
  3. Then you can see a warning appearing on the refresh .

    refresh is not a valid value for v-model. Expected: v-model

    image

Temporary workaround

Below is the definition of nut-pull-refresh in the web-types.json file:

https://cdn.jsdelivr.net/npm/@nutui/[email protected]/dist/smartips/web-types.json

{
  "name": "nut-pull-refresh",
  "slots": [],
  "events": [],
  "attributes": [
    {
      "name": "v-model",
      "default": "`false`",
      "description": "是否触发下拉刷新",
      "value": {
        "type": "boolean",
        "kind": "expression"
      }
    }
  ]
}

A key point here is that the value of type is boolean .

If you modify the type as follows, the warning disappears:

- "type": "boolean"
+ "type": "boolean "

image

image

But this approach is obviously unrealistic, because the web-types.json is generated by a third-party library and is syntactically correct.

Debugging and analysis

First, the warning is generated by the following code:

https://github.com/JetBrains/intellij-community/blob/1d4c2a0bf89a28abb2a469bdb5fee511ef05f52c/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributes/WebSymbolAttributeDescriptor.kt#L56-L60

image

The enumValues is a non-null value and is assigned in the following code:

https://github.com/JetBrains/intellij-community/blob/1d4c2a0bf89a28abb2a469bdb5fee511ef05f52c/xml/xml-psi-impl/src/com/intellij/html/webSymbols/attributes/impl/WebSymbolHtmlAttributeInfoImpl.kt#L67-L70

image

Since the value of attrValue?.kind is null , the kind is assigned the default value Kind.PLAIN , causing isHtmlBoolean to become ThreeState.YES .

After debugging I found the following code:

https://github.com/JetBrains/intellij-community/blob/1d4c2a0bf89a28abb2a469bdb5fee511ef05f52c/platform/webSymbols/src/com/intellij/webSymbols/webTypes/impl/WebTypesJsonContributionAdapter.kt#L250-L260

image

When copying attributeValue to HtmlAttributeValue() here, the kind field is missing.

So I guess the problem is caused here. If you modify it like the following, it may be able to fix the problem:

 attributeValue?.let { other ->
    it.required = other.required
    it.default = other.default
    it.type = other.type
+   it.kind = other.kind
 }

As said before I don't know how to test it in the intellij-community , so I changed the value during the breakpoint to test the effect.

The test result is that after modification, there will be no more warnings.

Modify the web-types.json file to make it reload.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions