|
15 | 15 | - [Caveats](#caveats) |
16 | 16 |
|
17 | 17 | ## Demo |
18 | | -You can check Vue-custom-element demos at **https://karol-f.github.io/vue-custom-element/** |
| 18 | +You can check out Vue-custom-element demos at **https://karol-f.github.io/vue-custom-element/** |
19 | 19 |
|
20 | 20 | ## Installation |
21 | 21 |
|
@@ -53,36 +53,36 @@ import 'document-register-element/build/document-register-element'; |
53 | 53 |
|
54 | 54 | ## Description |
55 | 55 |
|
56 | | -`Vue-custom-element` is a tiny wrapper around Vue components. It provide seamless way to use it in HTML, plain JavaScript, Vue, React, Angular etc., without manually initialising Vue. It's using power of Web Components' Custom Elements. |
| 56 | +`Vue-custom-element` is a tiny wrapper around Vue components. It provides a seamless way to use Vue components in HTML, plain JavaScript, Vue, React, Angular etc., without manually initialising Vue. It's using power of Web Components' Custom Elements. |
57 | 57 | * Works with Vue 0.12.x, 1.x and 2.x |
58 | 58 | * Small - 2.7 kb min+gzip, optional polyfill - 5 kb min+gzip |
59 | 59 |
|
60 | 60 | ### Why you might need `Vue-custom-element`? |
61 | 61 |  |
62 | 62 |
|
63 | | -It might be confusing for users to understand difference between Vue components, Custom Elements and it's use cases. |
| 63 | +It might be confusing for users to understand the different use cases of Vue components vs Custom Elements . |
64 | 64 |
|
65 | | -Why you might need `Vue-custom-element`? Simply, for your Vue components user's convinience. All they would need to do is include your JavaScript file and then they can: |
| 65 | +Why might you need `Vue-custom-element`? Simple, for your Vue components user's convenience. All they will need to do is include your JavaScript file and then they can: |
66 | 66 |
|
67 | | -* include HTML tag (e.g. `<my-component></my-component>`) in any time of document lifecycle. You can use your elements in e.g. SPA application just by including HTML tag - no Vue initialization or JavaScript usage is needed. Custom Elements will auto initialize when mounted into document. You can include them in e.g. Vue, Angular or React projects and browser will take care of detecting it and initialization |
68 | | -* use simple API that allows for interacting with underlaying Vue instance by changing attributes, props or listening to events |
| 67 | +* include components as HTML tags (e.g. `<my-component></my-component>`) at any time of the document lifecycle. You can use your elements in e.g. SPA application just by including HTML tag - no Vue initialization or JavaScript usage is needed. Custom Elements will auto initialize when mounted into document. You can include them in e.g. Vue, Angular or React projects and browser will take care of detecting it and initialization |
| 68 | +* use a simple API that allows for interacting with underlaying Vue instance by changing attributes, props or listening to events |
69 | 69 | * take advantage of features like lazy-loading, that allows for loading components on demand, only when user add them to document |
70 | 70 |
|
71 | 71 | ### Features |
72 | 72 |
|
73 | | -* **Simplicity** - only `tag-name` and Vue component `object` is needed for `Vue.customElement()` usage |
74 | | -* **Compatibility** - using optional polyfill we can support wide range of browsers, including IE9+, Android and IOS |
| 73 | +* **Simplicity** - only `tag-name` and Vue component `object` are needed for `Vue.customElement()` usage |
| 74 | +* **Compatibility** - using the optional polyfills a wide range of browsers is supported, including IE9+, Android and IOS |
75 | 75 | * **Full featured** - you can use nesting, HMR, slots, lazy-loading, native Custom Elements callbacks. |
76 | 76 | * reactive props and HTML attributes |
77 | 77 | * automatic props casting (numbers, booleans) so they won't be available as strings but proper data types |
78 | 78 | * listening to Vue component $emit'ed events |
79 | | - * 'default' and 'named' slots are available for passing static content, check demo for example |
| 79 | + * 'default' and 'named' slots are available for passing static content, check out the demo for an example |
80 | 80 | * Hot Module Replacement for seamless developer experience (unminimized build, Vue 2.x+) |
81 | | - * lazy-loading - you can download component after it's attached to document. Useful for e.g. UI library authors. Check demo for example |
82 | | - * detecting if detached callback is not invoked due to opening vue-custom-element in modal - element is then detached and attached to DOM again. It would be undesirable to destroy it immediately |
83 | | -* **Custom Elements v1** - compatible with latest specification. Vue-custom-element will use native implementation if supported |
| 81 | + * lazy-loading - you can download a component after it's attached to document. Useful for e.g. UI library authors. Check out the demo for an example |
| 82 | + * detect if detached callback is not invoked due to opening vue-custom-element in modal - element is then detached and attached to DOM again. It would be undesirable to destroy it immediately |
| 83 | +* **Custom Elements v1** - compatible with latest specifications. Vue-custom-element will use native implementation if supported |
84 | 84 |
|
85 | | -Check demos site to see it in action. |
| 85 | +Check out the demo site to see it in action. |
86 | 86 |
|
87 | 87 | ## Example |
88 | 88 | For additional examples and detailed description check the demos page. |
@@ -116,15 +116,15 @@ document.querySelector('widget-vue').prop2 = 'another string' // set prop value |
116 | 116 | You can also change `<widget-vue>` HTML attributes and changes will be instantly reflected. |
117 | 117 |
|
118 | 118 |
|
119 | | -## Browsers support |
| 119 | +## Browser support |
120 | 120 |
|
121 | 121 | | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/firefox.png" alt="Firefox" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome.png" alt="Chrome" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari.png" alt="Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/opera.png" alt="Opera" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Opera | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari-ios.png" alt="iOS Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>iOS | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome-android.png" alt="Chrome for Android" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Android | |
122 | 122 | |:---------:|:---------:|:---------:|:---------:|:---------:|:---------:| |
123 | 123 | | 59+ (--flag)| 54+ | 10.1+ | 42+ | 10.3+ | 55+ |
124 | 124 |
|
125 | 125 | [Custom Elements v1 support](http://caniuse.com/#feat=custom-elementsv1) |
126 | 126 |
|
127 | | -#### With optional polyfill |
| 127 | +#### With optional polyfills |
128 | 128 |
|
129 | 129 | | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/edge.png" alt="IE / Edge" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/firefox.png" alt="Firefox" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome.png" alt="Chrome" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari.png" alt="Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/opera.png" alt="Opera" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Opera | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/safari-ios.png" alt="iOS Safari" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>iOS | [<img src="https://raw.githubusercontent.com/godban/browsers-support-badges/master/src/images/chrome-android.png" alt="Chrome for Android" width="16px" height="16px" />](http://godban.github.io/browsers-support-badges/)</br>Android | |
130 | 130 | |:---------:|:---------:|:---------:|:---------:|:---------:|:---------:|:---------:| |
@@ -196,21 +196,21 @@ Vue.customElement('my-element', MyElement, { |
196 | 196 | }); |
197 | 197 | ``` |
198 | 198 |
|
199 | | -Callbacks are executed before lifecycle hooks from Vue component passed to Vue-custom-element. It's better idea just to use Vue component lifecycle hooks (e.g. `created`, `mounted`, `beforeDestroy`). |
| 199 | +Callbacks are executed before the lifecycle hooks from Vue component passed to Vue-custom-element. It's a better idea to just use Vue component lifecycle hooks (e.g. `created`, `mounted`, `beforeDestroy`). |
200 | 200 |
|
201 | 201 | ## How does it work? |
202 | 202 |  |
203 | 203 |
|
204 | | -Inside HTML tag of defined custom element, Vue-custom-element will create: |
| 204 | +Inside HTML tags of the defined custom element, Vue-custom-element will create: |
205 | 205 |
|
206 | 206 | * Proxy component for seamless Hot Module Replacement, using render function for performance (Vue 2.x+) |
207 | | -* Vue component passed to Vue-custom-element |
| 207 | +* Vue component is passed to Vue-custom-element |
208 | 208 |
|
209 | 209 | Custom Element HTML tag will expose API to interact with underlying Vue component - you can change HTML attributes or props, using JavaScript. |
210 | 210 |
|
211 | 211 | ## Testing |
212 | 212 |
|
213 | | -For advanced access, when exposed API is not enough, defined custom element will expose Vue instance via `getVueInstance()` method. |
| 213 | +For advanced access, when exposed API is not enough, defined custom element can expose Vue instance via `getVueInstance()` method. |
214 | 214 |
|
215 | 215 | ```javascript |
216 | 216 | console.info(document.querySelector('widget-vue').getVueInstance()) |
|
0 commit comments