Skip to content

Commit a46847d

Browse files
committed
tweak wording, correct typos and adjust grammar
1 parent 32a95c4 commit a46847d

File tree

9 files changed

+59
-60
lines changed

9 files changed

+59
-60
lines changed

src/guide/components/async.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Basic Usage
44

5-
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a [`defineAsyncComponent`](/api/general.html#defineasynccomponent) method:
5+
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a [`defineAsyncComponent`](/api/general.html#defineasynccomponent) function:
66

77
```js
88
import { defineAsyncComponent } from 'vue'
@@ -16,7 +16,7 @@ const AsyncComp = defineAsyncComponent(() => {
1616
// ... use `AsyncComp` like a normal component
1717
```
1818

19-
As you can see, this method accepts a loader function that returns a Promise. The Promise's `resolve` callback should be called when you have retrieved your component definition from the server. You can also call `reject(reason)` to indicate the load has failed.
19+
As you can see, `defineAsyncComponent` accepts a loader function that returns a Promise. The Promise's `resolve` callback should be called when you have retrieved your component definition from the server. You can also call `reject(reason)` to indicate the load has failed.
2020

2121
[ES module dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports) also returns a Promise, so most of the time we will use it in combination with `defineAsyncComponent`. Bundlers like Vite and webpack also support the syntax, so we can use it to import Vue SFCs:
2222

src/guide/components/attrs.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Then the final rendered DOM would now become:
4646

4747
### `v-on` Listener Inheritance
4848

49-
Same rule applies to `v-on` event listeners:
49+
The same rule applies to `v-on` event listeners:
5050

5151
```vue-html
5252
<MyButton @click="onClick" />
@@ -94,15 +94,15 @@ export default {
9494

9595
</div>
9696

97-
The common scenario for disabling an attribute inheritance is when attributes need to be applied to other elements besides the root node. By setting the `inheritAttrs` option to `false`, you can take full control over where the fallthrough attributes should be applied to.
97+
The common scenario for disabling attribute inheritance is when attributes need to be applied to other elements besides the root node. By setting the `inheritAttrs` option to `false`, you can take full control over where the fallthrough attributes should be applied.
9898

9999
These fallthrough attributes can be accessed directly in template expressions as `$attrs`:
100100

101101
```vue-html
102102
<span>Fallthrough attributes: {{ $attrs }}</span>
103103
```
104104

105-
The `$attrs` object includes all attributes not included to component `props` and `emits` properties (e.g., `class`, `style`, `v-on` listeners, etc.).
105+
The `$attrs` object includes all attributes that are not declared by the component's `props` or `emits` options (e.g., `class`, `style`, `v-on` listeners, etc.).
106106

107107
Using our `<MyButton>` component example from the [previous section](#attribute-inheritance) - sometimes we may need to wrap the actual `<button>` element with an extra `<div>` for styling purposes:
108108

@@ -120,11 +120,11 @@ We want all fallthrough attributes like `class` and `v-on` listeners to be appli
120120
</div>
121121
```
122122

123-
Remember that [`v-bind` without argument](/guide/essentials/template-syntax.html#dynamically-binding-multiple-attributes) binds every property of an object as attributes to the target element.
123+
Remember that [`v-bind` without an argument](/guide/essentials/template-syntax.html#dynamically-binding-multiple-attributes) binds all the properties of an object as attributes of the target element.
124124

125125
## Attribute Inheritance on Multiple Root Nodes
126126

127-
Unlike single root node components, components with multiple root nodes do not have an automatic attribute fallthrough behavior. If `$attrs` are not bound explicitly, a runtime warning will be issued.
127+
Unlike components with a single root node, components with multiple root nodes do not have an automatic attribute fallthrough behavior. If `$attrs` are not bound explicitly, a runtime warning will be issued.
128128

129129
```vue-html
130130
<CustomLayout id="custom-layout" @click="changeValue" />

src/guide/components/events.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The `.once` modifier is also supported on component event listeners:
2929
<MyComponent @some-event.once="callback" />
3030
```
3131

32-
Like components and props, event names provide an automatic case transformation. Notice we emitted a camelCase event, but is able to listen to it using a kebab-cased listener in the parent. As with [props casing](/guide/components/props.html#prop-name-casing), we recommend using kebab-cased event listeners in templates.
32+
Like components and props, event names provide an automatic case transformation. Notice we emitted a camelCase event, but can listen for it using a kebab-cased listener in the parent. As with [props casing](/guide/components/props.html#prop-name-casing), we recommend using kebab-cased event listeners in templates.
3333

3434
:::tip
3535
Unlike native DOM events, component emitted events do **not** bubble. You can only listen to the events emitted by a direct child component.
@@ -45,7 +45,7 @@ It's sometimes useful to emit a specific value with an event. For example, we ma
4545
</button>
4646
```
4747

48-
Then when we listen to the event in the parent, we can use an inline arrow function as the listener, which allows us to access the event argument:
48+
Then, when we listen to the event in the parent, we can use an inline arrow function as the listener, which allows us to access the event argument:
4949

5050
```vue-html
5151
<MyButton @increase-by="(n) => count += n" />
@@ -169,12 +169,12 @@ See also: [Typing Component Emits](/guide/typescript/options-api.html#typing-com
169169
Although optional, it is recommended to define all emitted events in order to better document how a component should work. It also allows Vue to exclude known listeners from [fallthrough attributes](/guide/components/attrs.html#v-on-listener-inheritance).
170170

171171
:::tip
172-
If a native event (e.g., `click`) is defined in the `emits` option, the listener will now only listen to component-emitted `click` event and no longer respond to native `click` events.
172+
If a native event (e.g., `click`) is defined in the `emits` option, the listener will now only listen to component-emitted `click` events and no longer respond to native `click` events.
173173
:::
174174

175175
## Events Validation
176176

177-
Similar to prop type validation, an emitted event can be validated if it is defined with the Object syntax instead of the array syntax.
177+
Similar to prop type validation, an emitted event can be validated if it is defined with the object syntax instead of the array syntax.
178178

179179
To add validation, the event is assigned a function that receives the arguments passed to the `emit` call and returns a boolean to indicate whether the event is valid or not.
180180

@@ -385,7 +385,7 @@ By default, `v-model` on a component uses `modelValue` as the prop and `update:m
385385
<MyComponent v-model:title="bookTitle" />
386386
```
387387

388-
In this case, child component should expect a `title` prop and emit `update:title` event to update the parent value:
388+
In this case, the child component should expect a `title` prop and emit an `update:title` event to update the parent value:
389389

390390
<div class="composition-api">
391391

src/guide/components/props.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ We use [PascalCase for component tags](/guide/components/registration.html#compo
154154

155155
### Static vs. Dynamic Props
156156

157-
So far, you've seen props passed as static value, like in:
157+
So far, you've seen props passed as static values, like in:
158158

159159
```vue-html
160160
<BlogPost title="My journey with Vue" />
@@ -418,7 +418,7 @@ defineProps({
418418
```
419419

420420
:::tip
421-
Code inside the `defineProps()` argument **cannot access other variables declared in `<script setup>`**, because the entire expression is moved out to an outer function scoped when compiled.
421+
Code inside the `defineProps()` argument **cannot access other variables declared in `<script setup>`**, because the entire expression is moved to an outer function scope when compiled.
422422
:::
423423

424424
</div>
@@ -483,7 +483,7 @@ If using [Type-based props declarations](/api/sfc-script-setup.html#typescript-o
483483
<div class="options-api">
484484

485485
::: tip Note
486-
Note that props are validated **before** a component instance is created, so instance properties (e.g. `data`, `computed`, etc) will not be available inside `default` or `validator` functions.
486+
Note that props are validated **before** a component instance is created, so instance properties (e.g. `data`, `computed`, etc.) will not be available inside `default` or `validator` functions.
487487
:::
488488

489489
</div>

src/guide/components/provide-inject.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
## Props Drilling
66

7-
Usually, when we need to pass data from the parent to child component, we use [props](/guide/components/props). However, imagine the case where we have a large component tree, and a deeply nested component needs something from a distant ancestor component. With only props, we would have to pass the same prop across the entire parent chain:
7+
Usually, when we need to pass data from the parent to a child component, we use [props](/guide/components/props). However, imagine the case where we have a large component tree, and a deeply nested component needs something from a distant ancestor component. With only props, we would have to pass the same prop across the entire parent chain:
88

99
![props drilling diagram](./images/props-drilling.png)
1010

@@ -46,7 +46,7 @@ export default {
4646

4747
The `provide()` function accepts two arguments. The first argument is called the **injection key**, which can be a string or a `Symbol`. The injection key is used by descendent components to lookup the desired value to inject. A single component can call `provide()` multiple times with different injection keys to provide different values.
4848

49-
The second argument is the provided value. The value can be of any type. including reactive state such as refs:
49+
The second argument is the provided value. The value can be of any type, including reactive state such as refs:
5050

5151
```js
5252
import { ref, provide } from 'vue'
@@ -193,7 +193,7 @@ Here, the component will locate a property provided with the key `"message"`, an
193193

194194
### Injection Default Values
195195

196-
By default, `inject` assumes that the injected key is provided somewhere in the parent chian. In the case where the key is not provided, there will be a runtime warning.
196+
By default, `inject` assumes that the injected key is provided somewhere in the parent chain. In the case where the key is not provided, there will be a runtime warning.
197197

198198
If we want to make an injected property work with optional providers, we need to declare a default value, similar to props:
199199

@@ -221,11 +221,11 @@ export default {
221221
// when declaring default values for injections
222222
inject: {
223223
message: {
224-
from: 'message', // this is optional is using the same key for injection
224+
from: 'message', // this is optional if using the same key for injection
225225
default: 'default value'
226226
},
227227
user: {
228-
// make sure to use factory function for non-primitive values!
228+
// make sure to use a factory function for non-primitive values!
229229
default: () => ({ name: 'John' })
230230
}
231231
}
@@ -240,7 +240,7 @@ export default {
240240

241241
When using reactive provide / inject values, **it is recommended to keep any mutations to reactive state inside of the _provider_ whenever possible**. This ensures that the provided state and its possible mutations are co-located in the same component, making it easier to maintain in the future.
242242

243-
There may be times where we need to update the data from a injector component. In such cases, we recommend providing a method that is responsible for mutating the state:
243+
There may be times when we need to update the data from a injector component. In such cases, we recommend providing a function that is responsible for mutating the state:
244244

245245
```vue{7-9,13}
246246
<!-- inside provider component -->

src/guide/components/registration.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app
4040
.component('ComponentC', ComponentC)
4141
```
4242
43-
Globally registered components can be used in the template of any component instance within this application:
43+
Globally registered components can be used in the template of any component within this application:
4444
4545
```vue-html
4646
<!-- this will work in any component inside the app -->
@@ -55,15 +55,15 @@ This even applies to all subcomponents, meaning all three of these components wi
5555
5656
While convenient, global registration has a few drawbacks:
5757
58-
1. Global registration prevents build systems from removing unused components (a.k.a "tree-shaking"). If you globally register a component but ends up not using it anywhere in your app, it will still be included in the final bundle.
58+
1. Global registration prevents build systems from removing unused components (a.k.a "tree-shaking"). If you globally register a component but end up not using it anywhere in your app, it will still be included in the final bundle.
5959
60-
2. Global registration makes dependency relationships less explicit in large applications. It makes it difficult to locate a child component's implementation from a parent component using it. This can affect long term maintainability similar to using too many global variables.
60+
2. Global registration makes dependency relationships less explicit in large applications. It makes it difficult to locate a child component's implementation from a parent component using it. This can affect long-term maintainability similar to using too many global variables.
6161

62-
Local registration scopes the availability of the registered components to the current component only. It makes the dependency relationship more explicit, and is more tree-shaking-friendly.
62+
Local registration scopes the availability of the registered components to the current component only. It makes the dependency relationship more explicit, and is more tree-shaking friendly.
6363

6464
<div class="composition-api">
6565

66-
When using SFC with `<script setup>`, imported components are automatically local-registered:
66+
When using SFC with `<script setup>`, imported components are automatically registered locally:
6767

6868
```vue
6969
<script setup>
@@ -93,7 +93,7 @@ export default {
9393
</div>
9494
<div class="options-api">
9595

96-
Local registration are done using the `components` option:
96+
Local registration is done using the `components` option:
9797

9898
```vue
9999
<script>
@@ -128,7 +128,7 @@ Note that **locally registered components are _not_ also available in descendent
128128

129129
## Component Name Casing
130130

131-
Throughout the guide, we are using PascalCase for component registration names. This is because:
131+
Throughout the guide, we are using PascalCase names when registering components. This is because:
132132

133133
1. PascalCase names are valid JavaScript identifiers. This makes it easier to import and register components in JavaScript. It also helps IDEs with auto-completion.
134134

src/guide/components/slots.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For example, we may have a `<FancyButton>` component that supports usage like th
1414
</FancyButton>
1515
```
1616

17-
This is how the template of `<FancyButton>` looks like:
17+
The template of `<FancyButton>` looks like this:
1818

1919
```vue-html{2}
2020
<button class="fancy-btn">
@@ -124,7 +124,7 @@ We might want the text "Submit" to be rendered inside the `<button>` if the pare
124124
</button>
125125
```
126126

127-
Now when we use `<submit-button>` in a parent component, providing no content for the slot:
127+
Now when we use `<SubmitButton>` in a parent component, providing no content for the slot:
128128

129129
```vue-html
130130
<SubmitButton />
@@ -195,7 +195,7 @@ For these cases, the `<slot>` element has a special attribute, `name`, which can
195195

196196
A `<slot>` outlet without `name` implicitly has the name "default".
197197

198-
In a parent component using `<BaseLayout>`, we need a way to pass multiple slot content framgents, each targeting a different slot outlet. This is where **named slots** comes in.
198+
In a parent component using `<BaseLayout>`, we need a way to pass multiple slot content fragments, each targeting a different slot outlet. This is where **named slots** come in.
199199

200200
To pass a named slot, we need to use a `<template>` element with the `v-slot` directive, and then pass the name of the slot as an argument to `v-slot`:
201201

@@ -213,7 +213,7 @@ To pass a named slot, we need to use a `<template>` element with the `v-slot` di
213213

214214
<!-- https://www.figma.com/file/2BhP8gVZevttBu9oUmUUyz/named-slot -->
215215

216-
Here's the code passing content to all three slots to `<BaseLayout>` using the shorthand syntax:
216+
Here's the code passing content for all three slots to `<BaseLayout>` using the shorthand syntax:
217217

218218
```vue-html
219219
<BaseLayout>
@@ -232,7 +232,7 @@ Here's the code passing content to all three slots to `<BaseLayout>` using the s
232232
</BaseLayout>
233233
```
234234

235-
When a component accepts both default slot and named slots, all top-level non-`<template>` nodes are implciitly treated as content for default slot. So the above can also be written as:
235+
When a component accepts both a default slot and named slots, all top-level non-`<template>` nodes are implicitly treated as content for the default slot. So the above can also be written as:
236236

237237
```vue-html
238238
<BaseLayout>
@@ -317,7 +317,7 @@ function BaseLayout(slots) {
317317
</base-layout>
318318
```
319319

320-
Do note the expression is subject to the same [syntax constraints](/guide/essentials/template-syntax.html#directives) of dynamic directive arguments.
320+
Do note the expression is subject to the [syntax constraints](/guide/essentials/template-syntax.html#directives) of dynamic directive arguments.
321321

322322
## Scoped Slots
323323

@@ -337,9 +337,9 @@ In fact, we can do exactly that - we can pass attributes to a slot outlet just l
337337
Receiving the slot props is a bit different when using a single default slot vs. using named slots. We are going to show how to receive props using a single default slot first, by using `v-slot` directly on the child component tag:
338338

339339
```vue-html
340-
<MyComonent v-slot="slotProps">
340+
<MyComponent v-slot="slotProps">
341341
{{ slotProps.text }} {{ slotProps.count }}
342-
<MyComponent>
342+
</MyComponent>
343343
```
344344

345345
<div class="composition-api">
@@ -353,7 +353,7 @@ Receiving the slot props is a bit different when using a single default slot vs.
353353

354354
</div>
355355

356-
The props passed to the slot by the child is available as the value of the corresponding `v-slot` directive, which can be accessed by expressions inside the slot.
356+
The props passed to the slot by the child are available as the value of the corresponding `v-slot` directive, which can be accessed by expressions inside the slot.
357357

358358
You can think of a scoped slot as a function being passed into the child component. The child component then calls it and passing props as arguments:
359359

@@ -378,13 +378,12 @@ function MyComponent(slots) {
378378

379379
In fact, this is very close to how scoped slots are compiled, and how you would use scoped slots in manual [render functions](/guide/extras/render-function.html).
380380

381-
Notice how `v-slot="slotProps"` matches the slot function signature - this means similar to function arguments, we can use destructuring in `v-slot`:
382-
381+
Notice how `v-slot="slotProps"` matches the slot function signature. Just like with function arguments, we can use destructuring in `v-slot`:
383382

384383
```vue-html
385-
<MyComonent v-slot="{ text, count }">
384+
<MyComponent v-slot="{ text, count }">
386385
{{ text }} {{ count }}
387-
<MyComponent>
386+
</MyComponent>
388387
```
389388

390389
### Named Scoped Slots
@@ -456,9 +455,9 @@ Inside `<FancyList>`, we can render the same `<slot>` multiple times with differ
456455

457456
The `<FancyList>` use case we discussed above encapsulates both reusable logic (data fetching, pagination etc.) and visual output, while delegating part of the visual output to the consumer component via scoped slots.
458457

459-
If we push this concept a bit further, we can come up with components that only encapsulate logic and do not render anything by themselves - visual output is fully delegated to the consumer component with scoped slots. We call this type of components **Renderless Components**.
458+
If we push this concept a bit further, we can come up with components that only encapsulate logic and do not render anything by themselves - visual output is fully delegated to the consumer component with scoped slots. We call this type of component a **Renderless Component**.
460459

461-
An exmaple renderless component could be one that encapsulates the logic of tracking the current mouse position:
460+
An example renderless component could be one that encapsulates the logic of tracking the current mouse position:
462461

463462
```vue-html
464463
<MouseTracker v-slot="{ x, y }">

0 commit comments

Comments
 (0)