Skip to content

Commit 13d2e05

Browse files
committed
FEATURE | Add option to pass arguments to main wrap function to add attribute to the new Vue object before render
1 parent e2b8456 commit 13d2e05

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/index.js

+22-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
convertAttributeValue
1010
} from './utils.js'
1111

12-
export default function wrap (Vue, Component) {
12+
export default function wrap (Vue, Component, vueAttributeBeforeRender) {
1313
const isAsync = typeof Component === 'function' && !Component.cid
1414
let isInitialized = false
1515
let hyphenatedPropsList
@@ -83,23 +83,28 @@ export default function wrap (Vue, Component) {
8383
const self = super()
8484
self.attachShadow({ mode: 'open' })
8585

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+
}
94106
}
95-
},
96-
render (h) {
97-
return h(Component, {
98-
ref: 'inner',
99-
props: this.props
100-
}, this.slotChildren)
101-
}
102-
})
107+
))
103108

104109
// Use MutationObserver to react to future attribute & slot content change
105110
const observer = new MutationObserver(mutations => {

0 commit comments

Comments
 (0)