-
Notifications
You must be signed in to change notification settings - Fork 26
Description
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
-
Create an empty project and install dependencies.
npm i vue @nutui/nutui
-
Create a
Vuefile.<template> <nut-pull-refresh v-model="refresh" /> </template> <script setup lang="ts"> import { ref } from 'vue'; const refresh = ref(false); </script>
-
Then you can see a warning appearing on the
refresh.refresh is not a valid value for v-model. Expected: v-model
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 "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:
The enumValues is a non-null value and is assigned in the following code:
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:
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.






