Skip to content

Commit 4a37fe0

Browse files
yyx990803skirtles-codeydcjeff
authored
Apply suggestions from code review
Co-authored-by: skirtle <65301168+skirtles-code@users.noreply.github.com> Co-authored-by: Jeff Yang <32727188+ydcjeff@users.noreply.github.com>
1 parent 55505e7 commit 4a37fe0

File tree

9 files changed

+48
-47
lines changed

9 files changed

+48
-47
lines changed

src/api/directives.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@
246246
- **Modifiers:**
247247

248248
- `.camel` - transform the kebab-case attribute name into camelCase.
249-
- `.prop` - force a binding to be set as DOM property. <Badge text="3.2+"/>
250-
- `.attr` - force a binding to be set as DOM attribute. <Badge text="3.2+"/>
249+
- `.prop` - force a binding to be set as a DOM property. <Badge text="3.2+"/>
250+
- `.attr` - force a binding to be set as a DOM attribute. <Badge text="3.2+"/>
251251

252252
- **Usage:**
253253

@@ -299,7 +299,7 @@
299299
<svg><a :xlink:special="foo"></a></svg>
300300
```
301301

302-
When setting a binding on an element, Vue by default checks whether the element has the key defined as a property using an `in` operator check. If the property is defined, Vue will set the value as DOM property instead of an attribute. This should work in most cases, but you can override this behavior by explicitly using `.prop` or `.attr` modifiers. This is sometimes necessary especially when [working with custom elements](/guide/web-components.html#passing-dom-properties).
302+
When setting a binding on an element, Vue by default checks whether the element has the key defined as a property using an `in` operator check. If the property is defined, Vue will set the value as a DOM property instead of an attribute. This should work in most cases, but you can override this behavior by explicitly using `.prop` or `.attr` modifiers. This is sometimes necessary, especially when [working with custom elements](/guide/web-components.html#passing-dom-properties).
303303

304304
The `.prop` modifier also has a dedicated shorthand, `.`:
305305

@@ -481,15 +481,15 @@
481481
</div>
482482
```
483483

484-
When the component re-renders, if both `valueA` and `valueB` remains the same, all updates for this `<div>` and its children will be skipped. In fact, even the Virtual DOM vnode creation will also be skipped since the memoized copy of the sub-tree can be reused.
484+
When the component re-renders, if both `valueA` and `valueB` remain the same, all updates for this `<div>` and its children will be skipped. In fact, even the Virtual DOM VNode creation will also be skipped since the memoized copy of the sub-tree can be reused.
485485

486486
It is important to specify the memoization array correctly, otherwise we may skip updates that should indeed be applied.
487487

488488
This directive is provided solely for micro optimizations in performance-critical scenarios and should be rarely needed. The most common case where this may prove helpful is when rendering large `v-for` lists (where `length > 1000`):
489489

490490
```html
491491
<div v-for="item in list" :key="item.id" v-memo="[item.id === selected]">
492-
<p>ID: {{ id }} - selected: {{ item.id === selected }}</p>
492+
<p>ID: {{ item.id }} - selected: {{ item.id === selected }}</p>
493493
<p>...more child nodes</p>
494494
</div>
495495
```

src/api/global-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ document.body.appendChild(new MyVueElement({
270270
}))
271271
```
272272

273-
For more details on building Web Components with Vue, especially with Single File Components, see [Vue and Web Components](/guide/web-components#building-custom-elements-with-vue).
273+
For more details on building Web Components with Vue, especially with Single File Components, see [Vue and Web Components](/guide/web-components.html#building-custom-elements-with-vue).
274274

275275
## resolveComponent
276276

src/api/sfc-script-setup.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebarDepth: 1
88

99
- More succinct code with less boilerplate
1010
- Ability to declare props and emitted events using pure TypeScript
11-
- Better runtime performance (template is compiled into render function in the same scope without an intermediate proxy)
11+
- Better runtime performance (the template is compiled into a render function in the same scope, without an intermediate proxy)
1212
- Better IDE type-inference performance (less work for the language server to extract types from code)
1313

1414
## Basic Syntax
@@ -21,9 +21,9 @@ console.log('hello script setup')
2121
</script>
2222
```
2323

24-
The code inside are compiled as the content of the component's `setup()` function. This means unlike normal `<script>`, which only executes once when the component is first imported, code inside `<script setup>` will **execute every time an instance of the component is created**.
24+
The code inside is compiled as the content of the component's `setup()` function. This means that unlike normal `<script>`, which only executes once when the component is first imported, code inside `<script setup>` will **execute every time an instance of the component is created**.
2525

26-
### Top level bindings are exposed to template
26+
### Top-level bindings are exposed to template
2727

2828
When using `<script setup>`, any top-level bindings (including variables, function declarations, and imports) declared inside `<script setup>` are directly usable in the template:
2929

@@ -57,7 +57,7 @@ import { capitalize } from './helpers'
5757

5858
## Reactivity
5959

60-
Reactive state needs to be explicitly created using [Reactivity APIs](/api/basic-reactivity.html). Similar to returned values from the `setup()` functions, refs are automatically unwrapped when referenced in templates:
60+
Reactive state needs to be explicitly created using [Reactivity APIs](/api/basic-reactivity.html). Similar to values returned from a `setup()` function, refs are automatically unwrapped when referenced in templates:
6161

6262
```vue
6363
<script setup>
@@ -85,7 +85,7 @@ import MyComponent from './MyComponent.vue'
8585
</template>
8686
```
8787

88-
Think of `MyComponent` as being referenced as a variable. If you have used JSX before, the mental model is similar here. The kebab-case equivalent `<my-component>` also works in the template - however PascalCase component tags are strongly recommended for consistency. It also helps differentiating from native custom elements.
88+
Think of `MyComponent` as being referenced as a variable. If you have used JSX, the mental model is similar here. The kebab-case equivalent `<my-component>` also works in the template - however PascalCase component tags are strongly recommended for consistency. It also helps differentiating from native custom elements.
8989

9090
### Dynamic Components
9191

@@ -107,7 +107,7 @@ Note how the components can be used as variables in a ternary expression.
107107

108108
### Recursive Components
109109

110-
SFCs can implicitly refer to itself via its filename. E.g. a file named `FooBar.vue` can refer to itself as `<FooBar/>` in its template.
110+
An SFC can implicitly refer to itself via its filename. E.g. a file named `FooBar.vue` can refer to itself as `<FooBar/>` in its template.
111111

112112
Note this has lower priority than imported components. If you have a named import that conflicts with the component's inferred name, you can alias the import:
113113

@@ -177,7 +177,7 @@ const attrs = useAttrs()
177177

178178
## Usage alongside normal `<script>`
179179

180-
`<script setup>` can be used alongside normal `<script>`. A normal `<script>` maybe needed in cases where we need to:
180+
`<script setup>` can be used alongside normal `<script>`. A normal `<script>` may be needed in cases where we need to:
181181

182182
- Declare options that cannot be expressed in `<script setup>`, for example `inheritAttrs` or custom options enabled via plugins.
183183
- Declaring named exports.
@@ -200,9 +200,9 @@ export default {
200200
</script>
201201
```
202202

203-
## Top level await
203+
## Top-level `await`
204204

205-
Top level `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:
205+
Top-level `await` can be used inside `<script setup>`. The resulting code will be compiled as `async setup()`:
206206

207207
```vue
208208
<script setup>
@@ -232,7 +232,7 @@ const emit = defineEmits<{
232232

233233
- `defineProps` or `defineEmits` can only use either runtime declaration OR type declaration. Using both at the same time will result in a compile error.
234234

235-
- When using type declaration, equivalent runtime declaration is automatically generated from static analysis to remove the need of double declaration and still ensure correct runtime behavior.
235+
- When using type declaration, the equivalent runtime declaration is automatically generated from static analysis to remove the need for double declaration and still ensure correct runtime behavior.
236236

237237
- In dev mode, the compiler will try to infer corresponding runtime validation from the types. For example here `foo: String` is inferred from the `foo: string` type. If the type is a reference to an imported type, the inferred result will be `foo: null` (equal to `any` type) since the compiler does not have information of external files.
238238

@@ -243,7 +243,7 @@ const emit = defineEmits<{
243243
- As of now, the type declaration argument must be one of the following to ensure correct static analysis:
244244

245245
- A type literal
246-
- A reference to a an interface or a type literal in the same file
246+
- A reference to an interface or a type literal in the same file
247247

248248
Currently complex types and type imports from other files are not supported. It is theoretically possible to support type imports in the future.
249249

@@ -265,4 +265,4 @@ This will be compiled to equivalent runtime props `default` options. In addition
265265

266266
## Restriction: No Src Imports
267267

268-
Due to the difference in module execution semantics, code inside `<script setup>` relies on the context of an SFC. When moved into external `.js` or `.ts` files, it may lead to confusions for both developers and tools. Therefore, **`<script setup>`** cannot be used with the `src` attribute.
268+
Due to the difference in module execution semantics, code inside `<script setup>` relies on the context of an SFC. When moved into external `.js` or `.ts` files, it may lead to confusion for both developers and tools. Therefore, **`<script setup>`** cannot be used with the `src` attribute.

src/api/sfc-spec.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ export default {
6060

6161
### Custom Blocks
6262

63-
Additional custom blocks can be included in a `*.vue` file for any project specific needs, for example a `<docs>` block. Some real-world examples of custom blocks include:
63+
Additional custom blocks can be included in a `*.vue` file for any project-specific needs, for example a `<docs>` block. Some real-world examples of custom blocks include:
6464

6565
- [Gridsome: `<page-query>`](https://gridsome.org/docs/querying-data/)
66-
- [vite-plguin-vue-gql: `<gql>`](https://github.com/wheatjs/vite-plugin-vue-gql)
66+
- [vite-plugin-vue-gql: `<gql>`](https://github.com/wheatjs/vite-plugin-vue-gql)
6767
- [vue-i18n: `<i18n>`](https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n#i18n-custom-block)
6868

6969
Handling of Custom Blocks will depend on tooling - if you want to build your own custom block integrations, see [SFC Tooling](/api/sfc-tooling.html#custom-blocks-integration) for more details.
@@ -117,7 +117,7 @@ If you prefer splitting up your `*.vue` components into multiple files, you can
117117
<script src="./script.js"></script>
118118
```
119119

120-
Beware that `src` imports follow the same path resolution rules to webpack module requests, which means:
120+
Beware that `src` imports follow the same path resolution rules as webpack module requests, which means:
121121

122122
- Relative paths need to start with `./`
123123
- You can import resources from npm dependencies:
@@ -136,4 +136,4 @@ Beware that `src` imports follow the same path resolution rules to webpack modul
136136

137137
## Comments
138138

139-
Inside each block you shall use the comment syntax of the language being used (HTML, CSS, JavaScript, Jade, etc). For top-level comments, use HTML comment syntax: `<!-- comment contents here -->`
139+
Inside each block you shall use the comment syntax of the language being used (HTML, CSS, JavaScript, Pug, etc.). For top-level comments, use HTML comment syntax: `<!-- comment contents here -->`

src/api/sfc-style.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ Refer to the [CSS Modules spec](https://github.com/css-modules/css-modules) for
132132

133133
You can customize the property key of the injected classes object by giving the `module` attribute a value:
134134

135-
```html
135+
```vue
136136
<template>
137137
<p :class="classes.red">red</p>
138138
</template>
139139
140140
<style module="classes">
141-
.red {
142-
color: red;
143-
}
141+
.red {
142+
color: red;
143+
}
144144
</style>
145145
```
146146

@@ -190,4 +190,4 @@ p {
190190
</style>
191191
```
192192

193-
The actual value will be compiled into a hashed CSS custom property so the CSS is still static. The custom property will be applied to component's root element via inline styles and reactively updated if the source value changes.
193+
The actual value will be compiled into a hashed CSS custom property, so the CSS is still static. The custom property will be applied to the component's root element via inline styles and reactively updated if the source value changes.

src/api/sfc-tooling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ It is also recommended to use these online playgrounds to provide reproductions
1717

1818
### Vite
1919

20-
[Vite](https://vitejs.dev/) is a lightweight and fast build tool with first-class Vue SFC support. It is created by Evan You who is also the author of Vue itself! To get started with Vite + Vue, simply run:
20+
[Vite](https://vitejs.dev/) is a lightweight and fast build tool with first-class Vue SFC support. It is created by Evan You, who is also the author of Vue itself! To get started with Vite + Vue, simply run:
2121

2222
```sh
2323
npm init vite@latest
2424
```
2525

26-
Then select the Vue template and follow instructions.
26+
Then select the Vue template and follow the instructions.
2727

2828
- To learn more about Vite, check out the [Vite docs](https://vitejs.dev/guide/).
29-
- To configure Vue specific behavior in a Vite project, for example passing options to the Vue compiler, check out docs for [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue#readme).
29+
- To configure Vue-specific behavior in a Vite project, for example passing options to the Vue compiler, check out the docs for [@vitejs/plugin-vue](https://github.com/vitejs/vite/tree/main/packages/plugin-vue#readme).
3030

3131
The [SFC Playground](https://sfc.vuejs.org/) also supports downloading the files as a Vite project.
3232

@@ -71,7 +71,7 @@ Custom blocks are compiled into imports to the same Vue file with different requ
7171

7272
- If using Vue CLI or plain webpack, a webpack loader should be configured to transform the matched blocks. [[Example](https://vue-loader.vuejs.org/guide/custom-blocks.html#custom-blocks)]
7373

74-
## Lower Level Tools
74+
## Lower-Level Tools
7575

7676
### `@vue/compiler-sfc`
7777

src/guide/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ In a large application, it is necessary to divide the whole app into components
314314

315315
### Relation to Custom Elements
316316

317-
You may have noticed that Vue components look similar to **Custom Elements**, which are part of the [Web Components Spec](https://www.w3.org/wiki/WebComponents/). Indeed, parts of Vue's component design (for example the slot API) was influenced by the spec before it was natively implemented in browsers.
317+
You may have noticed that Vue components look similar to **Custom Elements**, which are part of the [Web Components Spec](https://www.w3.org/wiki/WebComponents/). Indeed, parts of Vue's component design (for example the slot API) were influenced by the spec before it was natively implemented in browsers.
318318

319319
The main difference is that Vue's component model is designed as a part of a coherent framework that provides many additional features necessary for building non-trivial applications, for example reactive templating and state management - both of which the spec does not cover.
320320

src/guide/single-file-component.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ SFC is a defining feature of Vue as a framework, and is the recommended approach
7373
- Static Site Generation (SSG)
7474
- Any non-trivial frontends where a build step can be justified for better development experience (DX).
7575

76-
That said, we do realize there are scenarios where SFCs can feel like an overkill. This is why Vue can still be used via plain JavaScript without a build step. If you are just looking for enhancing largely static HTML with light interactions, you can also check out [petite-vue](https://github.com/vuejs/petite-vue), a 5kb subset of Vue optimized for progressive enhancement.
76+
That said, we do realize there are scenarios where SFCs can feel like overkill. This is why Vue can still be used via plain JavaScript without a build step. If you are just looking for enhancing largely static HTML with light interactions, you can also check out [petite-vue](https://github.com/vuejs/petite-vue), a 5kb subset of Vue optimized for progressive enhancement.
7777

7878
## What About Separation of Concerns?
7979

8080
Some users coming from a traditional web development background may have the concern that SFCs are mixing different concerns in the same place - which HTML/CSS/JS were supposed to separate!
8181

82-
To answer this question, it is important for us to agree that **separation of concerns is not equal to separation of file types.** The ultimate goal of engieerning principles is to improve maintainability of codebases. Separation of concerns, when applied dogmatically as separation of file types, does not help us reach that goal in the context of increasingly complex frontend applications.
82+
To answer this question, it is important for us to agree that **separation of concerns is not equal to separation of file types.** The ultimate goal of engineering principles is to improve maintainability of codebases. Separation of concerns, when applied dogmatically as separation of file types, does not help us reach that goal in the context of increasingly complex frontend applications.
8383

8484
In modern UI development, we have found that instead of dividing the codebase into three huge layers that interweave with one another, it makes much more sense to divide them into loosely-coupled components and compose them. Inside a component, its template, logic, and styles are inherently coupled, and collocating them actually makes the component more cohesive and maintainable.
8585

0 commit comments

Comments
 (0)