File tree 2 files changed +35
-17
lines changed
2 files changed +35
-17
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ const CustomElement = wrap(Vue, () => import(`MyComponent.vue`))
46
46
47
47
window .customElements .define (' my-element' , CustomElement)
48
48
```
49
+ ### Usage with addtional attributes
50
+ ``` js
51
+ const vueAttributeBeforeRender = {
52
+ i18n: { locale: ' de' },
53
+ foo: { bar: ' test' },
54
+ };
55
+
56
+ const CustomElement = wrap (Vue, Component, vueAttributeBeforeRender)
57
+ ```
58
+ This will add the attribute to the
59
+ ``` js
60
+ new Vue ({ // attributes })
61
+ ` ` `
49
62
50
63
## Interface Proxying Details
51
64
Original file line number Diff line number Diff line change 9
9
convertAttributeValue
10
10
} from './utils.js'
11
11
12
- export default function wrap ( Vue , Component ) {
12
+ export default function wrap ( Vue , Component , vueAttributeBeforeRender ) {
13
13
const isAsync = typeof Component === 'function' && ! Component . cid
14
14
let isInitialized = false
15
15
let hyphenatedPropsList
@@ -83,23 +83,28 @@ export default function wrap (Vue, Component) {
83
83
const self = super ( )
84
84
self . attachShadow ( { mode : 'open' } )
85
85
86
- const wrapper = self . _wrapper = new Vue ( {
87
- name : 'shadow-root' ,
88
- customElement : self ,
89
- shadowRoot : self . shadowRoot ,
90
- data ( ) {
91
- return {
92
- props : { } ,
93
- slotChildren : [ ]
86
+ const wrapper = self . _wrapper = new Vue (
87
+ Object . assign (
88
+ vueAttributeBeforeRender , {
89
+ name : 'shadow-root' ,
90
+ customElement : self ,
91
+ shadowRoot : self . shadowRoot ,
92
+
93
+ data ( ) {
94
+ return {
95
+ props : { } ,
96
+ slotChildren : [ ]
97
+ }
98
+ } ,
99
+
100
+ render ( h ) {
101
+ return h ( Component , {
102
+ ref : 'inner' ,
103
+ props : this . props
104
+ } , this . slotChildren )
105
+ }
94
106
}
95
- } ,
96
- render ( h ) {
97
- return h ( Component , {
98
- ref : 'inner' ,
99
- props : this . props
100
- } , this . slotChildren )
101
- }
102
- } )
107
+ ) )
103
108
104
109
// Use MutationObserver to react to future attribute & slot content change
105
110
const observer = new MutationObserver ( mutations => {
You can’t perform that action at this time.
0 commit comments