Skip to content

Commit 0c40bdb

Browse files
committed
updates
1 parent 4987d87 commit 0c40bdb

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

source/api/directives.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Example inehriting individual properties (using the same data):
147147

148148
## Literal Directives
149149

150-
> Literal directives treat their attribute value as a plain string; they do not attempt to bind themselves to anything. All they do is executing the `bind()` function with the string value once.
150+
> Literal directives treat their attribute value as a plain string; they do not attempt to bind themselves to anything. All they do is executing the `bind()` function with the string value once. Literal directives accept mustache expressions inside their value, but these expressions will be evaludated only once on first compile and do not react to data changes.
151151
152152
### v-component
153153

@@ -159,7 +159,7 @@ Only respected when used in combination with `v-component`, `v-with` or `v-repea
159159

160160
### v-partial
161161

162-
Replace the element's innerHTML with a registered partial. Partials can be registered with `Vue.partial()` or passed inside the `partials` option. You can also use this syntax:
162+
Replace the element's innerHTML with a registered partial. Partials can be registered with `Vue.partial()` or passed inside the `partials` option. You can also use this syntax (which doesn't support expressions):
163163

164164
``` html
165165
<div>&#123;&#123;> my-partial&#125;&#125;</div>

source/api/instance-methods.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type: api
33
order: 4
44
---
55

6-
## Data Changes
6+
## Data
77

88
> You can observe data changes on a ViewModel. Note that all watch callbacks fire asynchronously. In addition, value changes are batched within an event loop. This means when a value changes multiple times within a single event loop, the callback will be fired only once with the latest value.
99
@@ -21,6 +21,19 @@ Watch a keypath on the vm's data object for changes and call the callback with t
2121

2222
Stop watching the given keypath. If a callback is given only that callback gets unwatched.
2323

24+
### vm.$get( keypath )
25+
26+
- **keypath** `String`
27+
28+
Retrieve a data value from the vm given a keypath. Non-existent paths always return `undefined`.
29+
30+
### vm.$set( keypath, value )
31+
32+
- **keypath** `String`
33+
- **value** `*`
34+
35+
Set a data value on the vm given a keypath. If the path doesn't exist it will be created.
36+
2437
## Cross-ViewModel Events
2538

2639
> Each vm is also an event emitter. When you have multiple nested ViewModels, you can use the event system to communicate between them.

source/guide/composition.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
title: Composing ViewModels
1+
title: Composing Components
22
type: guide
33
order: 10
44
---
55

66
## Registering a Component
77

8-
Vue.js allows you to treat registered ViewModel constructors as reusable components. To register a component, use the global `Vue.component()` method:
8+
Vue.js allows you to treat registered ViewModel constructors as reusable components that is conceptually similar to [Web Components](http://www.w3.org/TR/components-intro/), without requiring any polyfills. To register a component, use the global `Vue.component()` method:
99

1010
``` js
1111
var MyComponent = Vue.extend({
@@ -28,12 +28,14 @@ Then you can use it in a parent ViewModel's template:
2828
<div v-component="my-component"></div>
2929
```
3030

31-
If you prefer, all registered components can also be used in the form of a custom element tag:
31+
If you prefer, components can also be used in the form of a custom element tag:
3232

3333
``` html
3434
<my-component></my-component>
3535
```
3636

37+
<p class="tip">To avoid naming collisions with native elements and stay consistent with the W3C Custom Elements specification, the component's ID **must** contain a hyphen `-` to be usable as a custom tag.</p>
38+
3739
## Partials and {&#123;>yield&#125;}
3840

3941
You can use partials in templates with {&#123;>partial-id&#125;}, which inserts the partial registered via `Vue.partial('partial-id', '...')`. But there is a special reserved partial ID: `yield`. Basically, the `yield` partial inside a template serves as a insertion point for the original, pre-compile content inside the element. This syntax allows components to be easily nested and composed while maintaining their custom markup. For example:

source/guide/directives.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ Some directives don't create data bindings - they simply take the attribute valu
6464
<div v-component="my-component"></div>
6565
```
6666

67-
Here `"my-component"` is not a data property - it's a string ID that Vue.js uses to lookup the corresponding Component constructor. A full list of literal directives can be found in the [API reference](/api/directives.html#literal-directives).
67+
Here `"my-component"` is not a data property - it's a string ID that Vue.js uses to lookup the corresponding Component constructor.
68+
69+
Since Vue.js 0.9.4, you can also use mustache expressions inside literal directives. This allows you to dynamically resolve the type of component you want to use:
70+
71+
``` html
72+
<div v-component="{&#123; isOwner ? 'owner-panel' : 'guest-panel' &#125;}"></div>
73+
```
74+
75+
<p class="tip">Mustache expressions inside literal directives are evaluated only once. After the directive has been compiled, it will no longer react to value changes.</p>
76+
77+
A full list of literal directives can be found in the [API reference](/api/directives.html#literal-directives).
6878

6979
## Empty Directives
7080

0 commit comments

Comments
 (0)