Skip to content

Commit 931b2fd

Browse files
committed
updates for 0.12.9
1 parent aaefeb0 commit 931b2fd

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

source/api/directives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Alternatively, you can bind the directive directly to an Object. The keys of the
6161

6262
Internally, {{ Mustache }} interpolations inside attributes are compiled into computed `v-attr` directives.
6363

64-
Starting in 0.12.8, `v-attr` also sets the corresponding property on the element if the property exists. For example, `<input value="{% raw %}{{val}}{% endraw %}">` will not only update the attribute, but also set the value property. If the element doesn't have a corresponding property for the bound attribute, it will not be set.
64+
Starting in 0.12.8, when used on input elements' `value` attribute, `v-attr` also sets the corresponding `value` property on the element. For example, `<input value="{% raw %}{{val}}{% endraw %}">` will not only update the attribute, but also set the underlying JavaScript property.
6565

6666
<p class="tip">You should use `v-attr` instead of mustache binding when setting the `src` attribute on `<img>` elements. Your templates are parsed by the browser before being compiled by Vue.js, so the mustache binding will cause a 404 when the browser tries to fetch it as the image's URL.</p>
6767

source/guide/components.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ var parent = new Vue({
547547

548548
## Private Assets
549549

550-
Sometimes a component needs to use assets such as directives, filters and its own child components, but might want to keep these assets encapsulated so the component itself can be reused elsewhere. You can do that using the private assets instantiation options. Private assets will only be accessible by the instances of the owner component and its child components.
550+
Sometimes a component needs to use assets such as directives, filters and its own child components, but might want to keep these assets encapsulated so the component itself can be reused elsewhere. You can do that using the private assets instantiation options. Private assets will only be accessible by the instances of the owner component, components that inherit from it, and its child components in the view hierarchy.
551551

552552
``` js
553553
// All 5 types of assets
@@ -573,6 +573,8 @@ var MyComponent = Vue.extend({
573573
})
574574
```
575575

576+
<p class="tip">You can prohibit child components from accessing a parent component's private assets by setting `Vue.config.strict = true`.</p>
577+
576578
Alternatively, you can add private assets to an existing Component constructor using a chaining API similar to the global asset registration methods:
577579

578580
``` js
@@ -583,6 +585,40 @@ MyComponent
583585
// ...
584586
```
585587

588+
### Asset Naming Convention
589+
590+
Some assets, such as components and directives, appear in templates in the form of HTML attributes or HTML custom tags. Since HTML attribute names and tag names are **case-insensitive**, we often need to name our assets using dash-case instead of camelCase. **Starting in 0.12.9**, it is now supported to name your assets using camelCase, and use them in templates with dash-case.
591+
592+
**Example**
593+
594+
``` js
595+
// in a component definition
596+
components: {
597+
// register using camelCase
598+
myComponent: { /*... */ }
599+
}
600+
```
601+
602+
``` html
603+
<!-- use dash case in templates -->
604+
<my-component></my-component>
605+
```
606+
607+
This works nicely with [ES6 object literal shorthand](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_6):
608+
609+
``` js
610+
import compA from './components/a';
611+
import compB from './components/b';
612+
613+
export default {
614+
components: {
615+
// use in templates as <comp-a> and <comp-b>
616+
compA,
617+
compB
618+
}
619+
}
620+
```
621+
586622
## Content Insertion
587623

588624
When creating reusable components, we often need to access and reuse the original content in the hosting element, which are not part of the component (similar to the Angular concept of "transclusion".) Vue.js implements a content insertion mechanism that is compatible with the current Web Components spec draft, using the special `<content>` element to serve as insertion points for the original content.

0 commit comments

Comments
 (0)