Skip to content

Commit e63d3ea

Browse files
authored
Hide all style guide links and add outdated warnings on style guide pages (vuejs#3119)
* docs: hide all the style-guide links until it's ready * docs: add outdated warnings on style guide pages * docs: adjust v-for with v-if warnings * docs: add outdated warning to style-guide index
1 parent c66267e commit e63d3ea

File tree

7 files changed

+34
-8
lines changed

7 files changed

+34
-8
lines changed

src/guide/essentials/conditional.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ Generally speaking, `v-if` has higher toggle costs while `v-show` has higher ini
110110

111111
## `v-if` with `v-for` {#v-if-with-v-for}
112112

113+
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.
114+
113115
::: warning Note
114-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential#avoid-v-if-with-v-for) for details.
116+
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [list rendering guide](list#v-for-with-v-if) for details.
115117
:::
116-
117-
When `v-if` and `v-for` are both used on the same element, `v-if` will be evaluated first. See the [list rendering guide](list#v-for-with-v-if) for details.

src/guide/essentials/list.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ Similar to template `v-if`, you can also use a `<template>` tag with `v-for` to
223223

224224
## `v-for` with `v-if` {#v-for-with-v-if}
225225

226-
:::warning Note
227-
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence. Refer to [style guide](/style-guide/rules-essential#avoid-v-if-with-v-for) for details.
228-
:::
229-
230226
When they exist on the same node, `v-if` has a higher priority than `v-for`. That means the `v-if` condition will not have access to variables from the scope of the `v-for`:
231227

232228
```vue-html
@@ -249,6 +245,16 @@ This can be fixed by moving `v-for` to a wrapping `<template>` tag (which is als
249245
</template>
250246
```
251247

248+
:::warning Note
249+
It's **not** recommended to use `v-if` and `v-for` on the same element due to implicit precedence.
250+
251+
There are two common cases where this can be tempting:
252+
253+
- To filter items in a list (e.g. `v-for="user in users" v-if="user.isActive"`). In these cases, replace `users` with a new computed property that returns your filtered list (e.g. `activeUsers`).
254+
255+
- To avoid rendering a list if it should be hidden (e.g. `v-for="user in users" v-if="shouldShowUsers"`). In these cases, move the `v-if` to a container element (e.g. `ul`, `ol`).
256+
:::
257+
252258
## Maintaining State with `key` {#maintaining-state-with-key}
253259

254260
When Vue is updating a list of elements rendered with `v-for`, by default it uses an "in-place patch" strategy. If the order of the data items has changed, instead of moving the DOM elements to match the order of the items, Vue will patch each element in-place and make sure it reflects what should be rendered at that particular index.
@@ -275,7 +281,7 @@ When using `<template v-for>`, the `key` should be placed on the `<template>` co
275281
`key` here is a special attribute being bound with `v-bind`. It should not be confused with the property key variable when [using `v-for` with an object](#v-for-with-an-object).
276282
:::
277283

278-
[It is recommended](/style-guide/rules-essential#use-keyed-v-for) to provide a `key` attribute with `v-for` whenever possible, unless the iterated DOM content is simple (i.e. contains no components or stateful DOM elements), or you are intentionally relying on the default behavior for performance gains.
284+
It is recommended to provide a `key` attribute with `v-for` whenever possible, unless the iterated DOM content is simple (i.e. contains no components or stateful DOM elements), or you are intentionally relying on the default behavior for performance gains.
279285

280286
The `key` binding expects primitive values - i.e. strings and numbers. Do not use objects as `v-for` keys. For detailed usage of the `key` attribute, please see the [`key` API documentation](/api/built-in-special-attributes#key).
281287

src/style-guide/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ outline: deep
44

55
# Style Guide {#style-guide}
66

7+
::: warning Note
8+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
9+
:::
10+
711
This is the official style guide for Vue-specific code. If you use Vue in a project, it's a great reference to avoid errors, bikeshedding, and anti-patterns. However, we don't believe that any style guide is ideal for all teams or projects, so mindful deviations are encouraged based on past experience, the surrounding tech stack, and personal values.
812

913
For the most part, we also avoid suggestions about JavaScript or HTML in general. We don't mind whether you use semicolons or trailing commas. We don't mind whether your HTML uses single-quotes or double-quotes for attribute values. Some exceptions will exist however, where we've found that a particular pattern is helpful in the context of Vue.

src/style-guide/rules-essential.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Priority A Rules: Essential {#priority-a-rules-essential}
22

3+
::: warning Note
4+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5+
:::
6+
37
These rules help prevent errors, so learn and abide by them at all costs. Exceptions may exist, but should be very rare and only be made by those with expert knowledge of both JavaScript and Vue.
48

59
## Use multi-word component names {#use-multi-word-component-names}

src/style-guide/rules-recommended.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Priority C Rules: Recommended {#priority-c-rules-recommended}
22

3+
::: warning Note
4+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5+
:::
6+
37
Where multiple, equally good options exist, an arbitrary choice can be made to ensure consistency. In these rules, we describe each acceptable option and suggest a default choice. That means you can feel free to make a different choice in your own codebase, as long as you're consistent and have a good reason. Please do have a good reason though! By adapting to the community standard, you will:
48

59
1. Train your brain to more easily parse most of the community code you encounter

src/style-guide/rules-strongly-recommended.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Priority B Rules: Strongly Recommended {#priority-b-rules-strongly-recommended}
22

3+
::: warning Note
4+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5+
:::
6+
37
These rules have been found to improve readability and/or developer experience in most projects. Your code will still run if you violate them, but violations should be rare and well-justified.
48

59
## Component files {#component-files}

src/style-guide/rules-use-with-caution.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Priority D Rules: Use with Caution {#priority-d-rules-use-with-caution}
22

3+
::: warning Note
4+
This Vue.js Style Guide is outdated and needs to be reviewed. If you have any questions or suggestions, please [open an issue](https://github.com/vuejs/docs/issues/new).
5+
:::
6+
37
Some features of Vue exist to accommodate rare edge cases or smoother migrations from a legacy code base. When overused however, they can make your code more difficult to maintain or even become a source of bugs. These rules shine a light on potentially risky features, describing when and why they should be avoided.
48

59
## Element selectors with `scoped` {#element-selectors-with-scoped}

0 commit comments

Comments
 (0)