Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add FAQ for "Vue warn: Failed setting prop" #2068

Merged
merged 1 commit into from
May 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export default defineConfig({
}
]
},
{
text: 'FAQ',
link: '/guide/faq/'
},
{
text: 'Migrating from Vue 2',
link: '/migration/'
Expand Down Expand Up @@ -214,6 +218,10 @@ export default defineConfig({
}
]
},
{
text: 'FAQ',
link: '/guide/faq/'
},
{
text: 'Migrating from Vue 2',
link: '/migration/'
Expand Down
25 changes: 25 additions & 0 deletions docs/guide/faq/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# FAQ

[[toc]]

## Vue warn: Failed setting prop

```
[Vue warn]: Failed setting prop "prefix" on <component-stub>: value foo is invalid.
TypeError: Cannot set property prefix of #<Element> which has only a getter
```

This warning is shown in case you are using `shallowMount` or `stubs` with a property name that is shared with [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element).

Common property names that are shared with `Element`:
* `attributes`
* `children`
* `prefix`

See: https://developer.mozilla.org/en-US/docs/Web/API/Element

**Possible solutions**

1. Use `mount` instead of `shallowMount` to render without stubs
2. Ignore the warning by mocking `console.warn`
3. Rename the prop to not clash with `Element` properties