Skip to content

Commit 0db530c

Browse files
authored
Merge pull request #2 from vuejs/master
Sync 21-02-2019
2 parents a5fb247 + 577192b commit 0db530c

29 files changed

+981
-61
lines changed

assets/why-vue/arabic.js.srt

Lines changed: 586 additions & 0 deletions
Large diffs are not rendered by default.

src/images/logo-vuemastery.svg

Lines changed: 22 additions & 0 deletions
Loading

src/v2/api/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ type: api
698698

699699
### el
700700

701-
- **Type:** `string | HTMLElement`
701+
- **Type:** `string | Element`
702702

703703
- **Restriction:** only respected in instance creation via `new`.
704704

@@ -1311,7 +1311,7 @@ type: api
13111311
13121312
### vm.$el
13131313
1314-
- **Type:** `HTMLElement`
1314+
- **Type:** `Element`
13151315
13161316
- **Read only**
13171317
@@ -2642,7 +2642,7 @@ Used to denote a `<template>` element as a scoped slot.
26422642
</keep-alive>
26432643
```
26442644
2645-
<p class="tip">`<keep-alive>` does not work with functional components because they do not have instances to be cached.</p>
2645+
<p class="tip">`<keep-alive>` does not work with functional components because they do not have instances to be cached.</p>
26462646
26472647
- **See also:** [Dynamic Components - keep-alive](../guide/components.html#keep-alive)
26482648

src/v2/cookbook/debugging-in-vscode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Click on the Debugging icon in the Activity Bar to bring up the Debug view, then
5757
"webRoot": "${workspaceFolder}/src",
5858
"breakOnLoad": true,
5959
"sourceMapPathOverrides": {
60-
"webpack:///src/*": "${webRoot}/*"
60+
"webpack:///./src/*": "${webRoot}/*"
6161
}
6262
},
6363
{

src/v2/examples/grid-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ order: 3
66

77
> This is an example of creating a reusable grid component and using it with external data.
88
9-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/xkkbfL3L/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
9+
<iframe width="100%" height="500" src="https://jsfiddle.net/Tertia/vbyon64p/6/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

src/v2/guide/components-custom-events.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ this.$emit('myEvent')
1717
Listening to the kebab-cased version will have no effect:
1818

1919
```html
20+
<!-- Won't work -->
2021
<my-component v-on:my-event="doSomething"></my-component>
2122
```
2223

src/v2/guide/components-dynamic-async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ order: 105
1010

1111
Earlier, we used the `is` attribute to switch between components in a tabbed interface:
1212

13-
```html
13+
{% codeblock lang:html %}
1414
<component v-bind:is="currentTabComponent"></component>
15-
```
15+
{% endcodeblock %}
1616

1717
When switching between these components though, you'll sometimes want to maintain their state or avoid re-rendering for performance reasons. For example, when expanding our tabbed interface a little:
1818

src/v2/guide/components-edge-cases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ When the `inline-template` special attribute is present on a child component, th
331331
</my-component>
332332
```
333333

334+
Your inline template needs to be defined inside the DOM element to which Vue is attached.
335+
334336
<p class="tip">However, <code>inline-template</code> makes the scope of your templates harder to reason about. As a best practice, prefer defining templates inside the component using the <code>template</code> option or in a <code>&lt;template&gt;</code> element in a <code>.vue</code> file.</p>
335337

336338
### X-Templates
@@ -349,6 +351,8 @@ Vue.component('hello-world', {
349351
})
350352
```
351353

354+
Your x-template needs to be defined outside the DOM element to which Vue is attached.
355+
352356
<p class="tip">These can be useful for demos with large templates or in extremely small applications, but should otherwise be avoided, because they separate templates from the rest of the component definition.</p>
353357

354358
## Controlling Updates

src/v2/guide/components-props.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ To specify prop validations, you can provide an object with validation requireme
188188
``` js
189189
Vue.component('my-component', {
190190
props: {
191-
// Basic type check (`null` matches any type)
191+
// Basic type check (`null` and `undefined` values will pass any type validation)
192192
propA: Number,
193193
// Multiple possible types
194194
propB: [String, Number],

src/v2/guide/components-slots.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ As a rule, remember that:
8282
8383
## Fallback Content
8484

85-
There are cases when it's useful to specify fallback (i.e. default) content for a slot, to be be rendered only when no content is provided. For example, in a `<submit-button>` component:
85+
There are cases when it's useful to specify fallback (i.e. default) content for a slot, to be rendered only when no content is provided. For example, in a `<submit-button>` component:
8686

8787
```html
8888
<button type="submit">
@@ -225,7 +225,7 @@ Note that **`v-slot` can only be added to a `<template>`** (with [one exception]
225225

226226
## Scoped Slots
227227

228-
> Updated in 2.6.0+. [See here](#Deprecated-Syntax) for the deprecated syntax using the `slot-props` attribute.
228+
> Updated in 2.6.0+. [See here](#Deprecated-Syntax) for the deprecated syntax using the `slot-scope` attribute.
229229
230230
Sometimes, it's useful for slot content to have access to data only available in the child component. For example, imagine a `<current-user>` component with the following template:
231231

@@ -363,7 +363,7 @@ You can even define fallbacks, to be used in case a slot prop is undefined:
363363

364364
> New in 2.6.0+
365365
366-
Similar to `v-on` and `v-bind`, `v-slot` also has a shorthand, replacing everything before the argument (`v-slot:`) with the special symbol `#`. For example, `v-slot:header` and be rewritten as `#header`:
366+
Similar to `v-on` and `v-bind`, `v-slot` also has a shorthand, replacing everything before the argument (`v-slot:`) with the special symbol `#`. For example, `v-slot:header` can be rewritten as `#header`:
367367

368368
```html
369369
<base-layout>

src/v2/guide/components.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Components are reusable Vue instances with a name: in this case, `<button-counte
2828
</div>
2929
```
3030

31-
```js
31+
{% codeblock lang:js %}
3232
new Vue({ el: '#components-demo' })
33-
```
33+
{% endcodeblock %}
3434

3535
{% raw %}
3636
<div id="components-demo" class="demo">

src/v2/guide/conditional.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,17 @@ order: 7
66

77
## `v-if`
88

9-
In string templates, for example [Handlebars](https://handlebarsjs.com/), we would write a conditional block like this:
9+
The directive `v-if` is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value.
1010

1111
``` html
12-
<!-- Handlebars template -->
13-
{{#if ok}}
14-
<h1>Yes</h1>
15-
{{/if}}
16-
```
17-
18-
In Vue, we use the `v-if` directive to achieve the same:
19-
20-
``` html
21-
<h1 v-if="ok">Yes</h1>
12+
<h1 v-if="awesome">Vue is awesome!</h1>
2213
```
2314

2415
It is also possible to add an "else block" with `v-else`:
2516

2617
``` html
27-
<h1 v-if="ok">Yes</h1>
28-
<h1 v-else>No</h1>
18+
<h1 v-if="awesome">Vue is awesome!</h1>
19+
<h1 v-else>Oh no 😢</h1>
2920
```
3021

3122
### Conditional Groups with `v-if` on `<template>`

src/v2/guide/forms.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ You can use the `v-model` directive to create two-way data bindings on form inpu
1010

1111
<p class="tip">`v-model` will ignore the initial `value`, `checked` or `selected` attributes found on any form elements. It will always treat the Vue instance data as the source of truth. You should declare the initial value on the JavaScript side, inside the `data` option of your component.</p>
1212

13+
`v-model` internally uses different properties and emits different events for different input elements:
14+
- text and textarea elements use `value` property and `input` event;
15+
- checkboxes and radiobuttons use `checked` property and `change` event;
16+
- select fields use `value` as a prop and `change` as an event.
17+
1318
<p class="tip" id="vmodel-ime-tip">For languages that require an [IME](https://en.wikipedia.org/wiki/Input_method) (Chinese, Japanese, Korean etc.), you'll notice that `v-model` doesn't get updated during IME composition. If you want to cater for these updates as well, use `input` event instead.</p>
1419

1520
### Text

src/v2/guide/migration-vue-router.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ to a definition like below in your `routes` configuration:
211211

212212
If you need multiple aliases, you can also use an array syntax:
213213

214-
``` js
214+
{% codeblock lang:js %}
215215
alias: ['/manage', '/administer', '/administrate']
216-
```
216+
{% endcodeblock %}
217217

218218
{% raw %}
219219
<div class="upgrade-path">

src/v2/guide/migration.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ The implicitly assigned `$index` and `$key` variables have been removed in favor
210210

211211
`track-by` has been replaced with `key`, which works like any other attribute: without the `v-bind:` or `:` prefix, it is treated as a literal string. In most cases, you'd want to use a dynamic binding which expects a full expression instead of a key. For example, in place of:
212212

213-
``` html
213+
{% codeblock lang:html %}
214214
<div v-for="item in items" track-by="id">
215-
```
215+
{% endcodeblock %}
216216

217217
You would now write:
218218

219-
``` html
219+
{% codeblock lang:html %}
220220
<div v-for="item in items" v-bind:key="item.id">
221-
```
221+
{% endcodeblock %}
222222

223223
{% raw %}
224224
<div class="upgrade-path">
@@ -400,9 +400,9 @@ For enumerated attributes, in addition to the falsy values above, the string `"f
400400

401401
When used on a component, `v-on` now only listens to custom events `$emit`ted by that component. To listen for a native DOM event on the root element, you can use the `.native` modifier. For example:
402402

403-
``` html
403+
{% codeblock lang:html %}
404404
<my-component v-on:click.native="doSomething"></my-component>
405-
```
405+
{% endcodeblock %}
406406

407407
{% raw %}
408408
<div class="upgrade-path">
@@ -602,9 +602,9 @@ As you can see, `v-model`'s two-way binding doesn't make sense here. Setting `st
602602

603603
Instead, you should use an array of __objects__ so that `v-model` can update the field on the object. For example:
604604

605-
``` html
605+
{% codeblock lang:html %}
606606
<input v-for="obj in objects" v-model="obj.str">
607-
```
607+
{% endcodeblock %}
608608

609609
{% raw %}
610610
<div class="upgrade-path">
@@ -709,7 +709,7 @@ The `.literal` modifier has been removed, as the same can be easily achieved by
709709

710710
For example, you can update:
711711

712-
``` js
712+
``` html
713713
<p v-my-directive.literal="foo bar baz"></p>
714714
```
715715

@@ -990,9 +990,9 @@ computed: {
990990

991991
You can even order by multiple columns:
992992

993-
``` js
993+
{% codeblock lang:js %}
994994
_.orderBy(this.users, ['name', 'last_login'], ['asc', 'desc'])
995-
```
995+
{% endcodeblock %}
996996

997997
{% raw %}
998998
<div class="upgrade-path">
@@ -1070,9 +1070,9 @@ function pluralizeKnife (count) {
10701070

10711071
For a very naive implementation, you could do something like this:
10721072

1073-
``` js
1073+
{% codeblock lang:js %}
10741074
'$' + price.toFixed(2)
1075-
```
1075+
{% endcodeblock %}
10761076

10771077
In many cases though, you'll still run into strange behavior (e.g. `0.035.toFixed(2)` rounds up to `0.04`, but `0.045` rounds down to `0.04`). To work around these issues, you can use the [`accounting`](http://openexchangerates.github.io/accounting.js/) library to more reliably format currencies.
10781078

@@ -1365,9 +1365,9 @@ Instead, retrieve reactive data directly.
13651365

13661366
Use the native DOM API:
13671367

1368-
``` js
1368+
{% codeblock lang:js %}
13691369
myElement.appendChild(vm.$el)
1370-
```
1370+
{% endcodeblock %}
13711371

13721372
{% raw %}
13731373
<div class="upgrade-path">
@@ -1380,9 +1380,9 @@ myElement.appendChild(vm.$el)
13801380

13811381
Use the native DOM API:
13821382

1383-
``` js
1383+
{% codeblock lang:js %}
13841384
myElement.parentNode.insertBefore(vm.$el, myElement)
1385-
```
1385+
{% endcodeblock %}
13861386

13871387
{% raw %}
13881388
<div class="upgrade-path">
@@ -1395,15 +1395,15 @@ myElement.parentNode.insertBefore(vm.$el, myElement)
13951395

13961396
Use the native DOM API:
13971397

1398-
``` js
1398+
{% codeblock lang:js %}
13991399
myElement.parentNode.insertBefore(vm.$el, myElement.nextSibling)
1400-
```
1400+
{% endcodeblock %}
14011401

14021402
Or if `myElement` is the last child:
14031403

1404-
``` js
1404+
{% codeblock lang:js %}
14051405
myElement.parentNode.appendChild(vm.$el)
1406-
```
1406+
{% endcodeblock %}
14071407

14081408
{% raw %}
14091409
<div class="upgrade-path">
@@ -1416,9 +1416,9 @@ myElement.parentNode.appendChild(vm.$el)
14161416

14171417
Use the native DOM API:
14181418

1419-
``` js
1419+
{% codeblock lang:js %}
14201420
vm.$el.remove()
1421-
```
1421+
{% endcodeblock %}
14221422

14231423
{% raw %}
14241424
<div class="upgrade-path">

src/v2/guide/team.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,13 +1068,15 @@ order: 803
10681068
city: 'Washington, DC, USA',
10691069
languages: ['en', 'zh'],
10701070
work: {
1071-
role: 'Full Stack Engineer',
1071+
role: 'Senior Frontend Engineer',
10721072
org: 'GitLab (Meltano)',
10731073
},
1074+
reposOfficial: [
1075+
'vuejs/events'
1076+
],
10741077
github: 'bencodezen',
10751078
twitter: 'bencodezen',
10761079
links: [
1077-
'https://www.vuemeetups.org',
10781080
'https://bencodezen.io/'
10791081
]
10801082
},

src/v2/guide/transitioning-state.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,8 @@ Vue.component('animated-integer', {
425425

426426
new TWEEN.Tween({ tweeningValue: startValue })
427427
.to({ tweeningValue: endValue }, 500)
428-
.onUpdate(function (object) {
429-
vm.tweeningValue = object.tweeningValue.toFixed(0)
428+
.onUpdate(function () {
429+
vm.tweeningValue = this.tweeningValue.toFixed(0)
430430
})
431431
.start()
432432

src/v2/style-guide/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,9 +1215,9 @@ props: {
12151215
}
12161216
```
12171217

1218-
``` html
1218+
{% codeblock lang:html %}
12191219
<WelcomeMessage greetingText="hi"/>
1220-
```
1220+
{% endcodeblock %}
12211221
{% raw %}</div>{% endraw %}
12221222

12231223
{% raw %}<div class="style-example example-good">{% endraw %}
@@ -1229,9 +1229,9 @@ props: {
12291229
}
12301230
```
12311231

1232-
``` html
1232+
{% codeblock lang:html %}
12331233
<WelcomeMessage greeting-text="hi"/>
1234-
```
1234+
{% endcodeblock %}
12351235
{% raw %}</div>{% endraw %}
12361236

12371237

0 commit comments

Comments
 (0)