Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ export default function wrap (Vue, Component) {
}

class CustomElement extends HTMLElement {
constructor () {
super()
this.attachShadow({ mode: 'open' })
constructor (...args) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think ...args are necessary here, are they?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const self = super(...args)
self.attachShadow({ mode: 'open' })

const wrapper = this._wrapper = new Vue({
const wrapper = self._wrapper = new Vue({
name: 'shadow-root',
customElement: this,
shadowRoot: this.shadowRoot,
customElement: self,
shadowRoot: self.shadowRoot,
data () {
return {
props: {},
Expand All @@ -106,20 +106,20 @@ export default function wrap (Vue, Component) {
let hasChildrenChange = false
for (let i = 0; i < mutations.length; i++) {
const m = mutations[i]
if (isInitialized && m.type === 'attributes' && m.target === this) {
syncAttribute(this, m.attributeName)
if (isInitialized && m.type === 'attributes' && m.target === self) {
syncAttribute(self, m.attributeName)
} else {
hasChildrenChange = true
}
}
if (hasChildrenChange) {
wrapper.slotChildren = Object.freeze(toVNodes(
wrapper.$createElement,
this.childNodes
self.childNodes
))
}
})
observer.observe(this, {
observer.observe(self, {
childList: true,
subtree: true,
characterData: true,
Expand Down