Skip to content

Commit 166f6fc

Browse files
zoeyfyiyyx990803
authored andcommitted
fix: customElement constructor for compatibility with other polyfills (#27)
1 parent f0792ad commit 166f6fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ export default function wrap (Vue, Component) {
8080

8181
class CustomElement extends HTMLElement {
8282
constructor () {
83-
super()
84-
this.attachShadow({ mode: 'open' })
83+
const self = super()
84+
self.attachShadow({ mode: 'open' })
8585

86-
const wrapper = this._wrapper = new Vue({
86+
const wrapper = self._wrapper = new Vue({
8787
name: 'shadow-root',
88-
customElement: this,
89-
shadowRoot: this.shadowRoot,
88+
customElement: self,
89+
shadowRoot: self.shadowRoot,
9090
data () {
9191
return {
9292
props: {},
@@ -106,20 +106,20 @@ export default function wrap (Vue, Component) {
106106
let hasChildrenChange = false
107107
for (let i = 0; i < mutations.length; i++) {
108108
const m = mutations[i]
109-
if (isInitialized && m.type === 'attributes' && m.target === this) {
110-
syncAttribute(this, m.attributeName)
109+
if (isInitialized && m.type === 'attributes' && m.target === self) {
110+
syncAttribute(self, m.attributeName)
111111
} else {
112112
hasChildrenChange = true
113113
}
114114
}
115115
if (hasChildrenChange) {
116116
wrapper.slotChildren = Object.freeze(toVNodes(
117117
wrapper.$createElement,
118-
this.childNodes
118+
self.childNodes
119119
))
120120
}
121121
})
122-
observer.observe(this, {
122+
observer.observe(self, {
123123
childList: true,
124124
subtree: true,
125125
characterData: true,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy